Skip to content

Commit

Permalink
ci(workflow): restore publish wasm binary
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Dec 8, 2023
1 parent daa207b commit bf50caf
Showing 1 changed file with 49 additions and 54 deletions.
103 changes: 49 additions & 54 deletions scripts/publish-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,60 +73,55 @@ const cwd = process.cwd()
)

// Update name/version of wasm packages and publish
// const pkgDirectory = 'packages/next-swc/crates/wasm'
// let wasmDir = path.join(cwd, pkgDirectory)

// await Promise.all(
// ['web', 'nodejs'].map(async (wasmTarget) => {
// await publishSema.acquire()

// let wasmPkg = JSON.parse(
// await readFile(path.join(wasmDir, `pkg-${wasmTarget}/package.json`))
// )
// wasmPkg.name = `@next/swc-wasm-${wasmTarget}`
// wasmPkg.version = version
// wasmPkg.repository = {
// type: 'git',
// url: 'https://github.com/vercel/next.js',
// directory: pkgDirectory,
// }

// await writeFile(
// path.join(wasmDir, `pkg-${wasmTarget}/package.json`),
// JSON.stringify(wasmPkg, null, 2)
// )

// try {
// await execa(
// `npm`,
// [
// 'publish',
// `${path.join(wasmDir, `pkg-${wasmTarget}`)}`,
// '--access',
// 'public',
// ...(version.includes('canary') ? ['--tag', 'canary'] : []),
// ],
// { stdio: 'inherit' }
// )
// } catch (err) {
// // don't block publishing other versions on single platform error
// console.error(`Failed to publish`, wasmTarget, err)

// if (
// err.message &&
// err.message.includes(
// 'You cannot publish over the previously published versions'
// )
// ) {
// console.error('Ignoring already published error', wasmTarget)
// } else {
// // throw err
// }
// } finally {
// publishSema.release()
// }
// })
// )
const pkgDirectory = 'packages/next-swc/crates/wasm'
let wasmDir = path.join(cwd, pkgDirectory)
await Promise.all(
['web', 'nodejs'].map(async (wasmTarget) => {
await publishSema.acquire()
let wasmPkg = JSON.parse(
await readFile(path.join(wasmDir, `pkg-${wasmTarget}/package.json`))
)
wasmPkg.name = `@next/swc-wasm-${wasmTarget}`
wasmPkg.version = version
wasmPkg.repository = {
type: 'git',
url: 'https://github.com/vercel/next.js',
directory: pkgDirectory,
}
await writeFile(
path.join(wasmDir, `pkg-${wasmTarget}/package.json`),
JSON.stringify(wasmPkg, null, 2)
)
try {
await execa(
`npm`,
[
'publish',
`${path.join(wasmDir, `pkg-${wasmTarget}`)}`,
'--access',
'public',
...(version.includes('canary') ? ['--tag', 'canary'] : []),
],
{ stdio: 'inherit' }
)
} catch (err) {
// don't block publishing other versions on single platform error
console.error(`Failed to publish`, wasmTarget, err)
if (
err.message &&
err.message.includes(
'You cannot publish over the previously published versions'
)
) {
console.error('Ignoring already published error', wasmTarget)
} else {
// throw err
}
} finally {
publishSema.release()
}
})
)

// Update optional dependencies versions
let nextPkg = JSON.parse(
Expand Down

0 comments on commit bf50caf

Please sign in to comment.