-
Notifications
You must be signed in to change notification settings - Fork 107
chore: update the release instruction #1627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||||||||||||||||||||||||||
| import assert from 'assert'; | ||||||||||||||||||||||||||||||
| import 'zx/globals'; | ||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||
| ensureGitStatus, | ||||||||||||||||||||||||||||||
|
|
@@ -9,11 +10,7 @@ import { | |||||||||||||||||||||||||||||
| } from './utils'; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| (async () => { | ||||||||||||||||||||||||||||||
| if (argv.build) { | ||||||||||||||||||||||||||||||
| await build(); | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| await run(); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| await run(); | ||||||||||||||||||||||||||||||
| })().catch((e) => { | ||||||||||||||||||||||||||||||
| console.error(e); | ||||||||||||||||||||||||||||||
| process.exit(1); | ||||||||||||||||||||||||||||||
|
|
@@ -22,17 +19,20 @@ import { | |||||||||||||||||||||||||||||
| async function run() { | ||||||||||||||||||||||||||||||
| await ensureGitStatus(); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // check docker status | ||||||||||||||||||||||||||||||
| console.log('Check docker status'); | ||||||||||||||||||||||||||||||
| await $`docker ps`; | ||||||||||||||||||||||||||||||
| const commitId = (await $`git rev-parse HEAD`).stdout.trim(); | ||||||||||||||||||||||||||||||
| const artifactsFile = `artifacts-${commitId}.zip`; | ||||||||||||||||||||||||||||||
| const hasArtifacts = fs.existsSync(path.join(process.cwd(), artifactsFile)); | ||||||||||||||||||||||||||||||
| assert(hasArtifacts, `${artifactsFile} not found in cwd`); | ||||||||||||||||||||||||||||||
|
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 增加了对 在第22-25行,您增加了获取 🛠️ Refactor suggestion 重复检查 您在 Also applies to: 54-57 |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| const nodePkgPath = rootPkgPath(); | ||||||||||||||||||||||||||||||
| const nodePkg = loadPkg(nodePkgPath); | ||||||||||||||||||||||||||||||
| const { newVersion, tag, branch } = await queryNewVersion(nodePkg); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| nodePkg.version = newVersion; | ||||||||||||||||||||||||||||||
| fs.writeFileSync(nodePkgPath, JSON.stringify(nodePkg, null, 2) + '\n'); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| await build(); | ||||||||||||||||||||||||||||||
| await artifacts(artifactsFile); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| await $`npm publish --tag ${tag} --access public`; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -42,84 +42,17 @@ async function run() { | |||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| async function build() { | ||||||||||||||||||||||||||||||
| // clean | ||||||||||||||||||||||||||||||
| await $`rm -rf ./*.node`; | ||||||||||||||||||||||||||||||
| await $`find ./npm -name '*.node' | xargs rm -f`; | ||||||||||||||||||||||||||||||
| await $`rm -rf ./dist`; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // build linux *.node | ||||||||||||||||||||||||||||||
| console.log('linux building started...'); | ||||||||||||||||||||||||||||||
| const start = Date.now(); | ||||||||||||||||||||||||||||||
| const cargoRoot = path.join(__dirname, '../../..'); | ||||||||||||||||||||||||||||||
| // clean sailfish | ||||||||||||||||||||||||||||||
| // since its lock files may cause build error | ||||||||||||||||||||||||||||||
| await $`rm -rf ${cargoRoot}/target/release/build/sailfish*`; | ||||||||||||||||||||||||||||||
| await build_linux_binding('gnu'); | ||||||||||||||||||||||||||||||
| await build_linux_binding('musl'); | ||||||||||||||||||||||||||||||
| await $`pnpm run format`; | ||||||||||||||||||||||||||||||
| const duration = (Date.now() - start) / 1000; | ||||||||||||||||||||||||||||||
| console.log(`linux building done ${duration}s`); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // build macos *.node | ||||||||||||||||||||||||||||||
| await $`cargo build --lib -r --target x86_64-apple-darwin`; | ||||||||||||||||||||||||||||||
| await $`pnpm run build:mac:x86`; | ||||||||||||||||||||||||||||||
| await $`cargo build --lib -r --target aarch64-apple-darwin`; | ||||||||||||||||||||||||||||||
| await $`pnpm run build:mac:aarch`; | ||||||||||||||||||||||||||||||
| await $`strip -x ./mako.darwin-*.node`; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // build src | ||||||||||||||||||||||||||||||
| await $`pnpm run build`; | ||||||||||||||||||||||||||||||
| await $`pnpm run src:build`; | ||||||||||||||||||||||||||||||
| await $`pnpm run format`; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // move artifacts to npm | ||||||||||||||||||||||||||||||
| await $`pnpm run artifacts:local`; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| async function build_linux_binding(cLib: 'musl' | 'gnu') { | ||||||||||||||||||||||||||||||
| const isArm = process.arch === 'arm64'; | ||||||||||||||||||||||||||||||
| const cargoBase = path.join( | ||||||||||||||||||||||||||||||
| process.env['CARGO_HOME'] || process.env['HOME']!, | ||||||||||||||||||||||||||||||
| '.cargo', | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| const cargoMapOption = (p: string) => [ | ||||||||||||||||||||||||||||||
| '-v', | ||||||||||||||||||||||||||||||
| `${path.join(cargoBase, p)}:${path.join('/usr/local/cargo', p)}`, | ||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||
| const rustupRoot = path.join(os.homedir(), '.rustup'); | ||||||||||||||||||||||||||||||
| const makoRoot = path.join(__dirname, '../../..'); | ||||||||||||||||||||||||||||||
| const volumeOptions = [ | ||||||||||||||||||||||||||||||
| ...cargoMapOption('config'), | ||||||||||||||||||||||||||||||
| ...cargoMapOption('git/db'), | ||||||||||||||||||||||||||||||
| ...cargoMapOption('registry/cache'), | ||||||||||||||||||||||||||||||
| ...cargoMapOption('registry/index'), | ||||||||||||||||||||||||||||||
| ...[`-v`, `${makoRoot}:/build`], | ||||||||||||||||||||||||||||||
| ...[`-v`, `${rustupRoot}:/usr/local/rustup`], | ||||||||||||||||||||||||||||||
| ...[`-w`, `/build`], | ||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||
| const containerCMD = [ | ||||||||||||||||||||||||||||||
| `cargo build -r --lib --target x86_64-unknown-linux-${cLib}`, | ||||||||||||||||||||||||||||||
| 'cd packages/mako', | ||||||||||||||||||||||||||||||
| `npm run build:linux:${cLib}`, | ||||||||||||||||||||||||||||||
| 'strip mako.linux*.node', | ||||||||||||||||||||||||||||||
| ].join('&&'); | ||||||||||||||||||||||||||||||
| const envOptions: string[] = []; | ||||||||||||||||||||||||||||||
| if (process.env['RUSTUP_DIST_SERVER']) { | ||||||||||||||||||||||||||||||
| envOptions.push( | ||||||||||||||||||||||||||||||
| ...['-e', `RUSTUP_DIST_SERVER=${process.env['RUSTUP_DIST_SERVER']}`], | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| if (process.env[`RUSTUP_UPDATE_ROOT`]) { | ||||||||||||||||||||||||||||||
| envOptions.push( | ||||||||||||||||||||||||||||||
| ...['-e', `RUSTUP_UPDATE_ROOT=${process.env[`RUSTUP_UPDATE_ROOT`]}`], | ||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| const options = ['--rm', ...volumeOptions, ...envOptions]; | ||||||||||||||||||||||||||||||
| if (isArm) { | ||||||||||||||||||||||||||||||
| options.push(...['--platform', 'linux/amd64']); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| const image = | ||||||||||||||||||||||||||||||
| cLib === 'gnu' | ||||||||||||||||||||||||||||||
| ? 'ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-debian' | ||||||||||||||||||||||||||||||
| : 'ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine'; | ||||||||||||||||||||||||||||||
| await $`docker run ${options} ${image} bash -c ${containerCMD}`; | ||||||||||||||||||||||||||||||
| async function artifacts(artifactsFile: string) { | ||||||||||||||||||||||||||||||
| await $`rm -rf *.node`; | ||||||||||||||||||||||||||||||
| await $`unzip ${artifactsFile}`; | ||||||||||||||||||||||||||||||
| await $`npm run artifacts:local`; | ||||||||||||||||||||||||||||||
|
Comment on lines
+54
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 新增加的 在第54-57行,您新增了 可以考虑如下修改,添加错误捕获: async function artifacts(artifactsFile: string) {
+ try {
await $`rm -rf *.node`;
await $`unzip ${artifactsFile}`;
await $`npm run artifacts:local`;
+ } catch (error) {
+ console.error(`Artifacts processing failed: ${error}`);
+ process.exit(1);
+ }
}📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.