-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
ci: avoid unnecessary release builds #5191
Open
cijiugechu
wants to merge
2
commits into
rollup:master
Choose a base branch
from
cijiugechu:ci/avoid-unnecessary-release-build
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env node | ||
|
||
import { exec } from 'node:child_process'; | ||
import { env, exit } from 'node:process'; | ||
import argsParser from 'yargs-parser'; | ||
|
||
const parsedArguments = argsParser(process.argv.slice(2)); | ||
const binding = parsedArguments.binding; | ||
const target = parsedArguments.target; | ||
|
||
const isRelease = env.ROLLUP_RELEASE === 'releasing' || env.BUILD_ARTEFACTS === 'build'; | ||
|
||
const buildCommands = { | ||
napi: { | ||
dev: 'napi build --platform --dts native.d.ts --js false --cargo-cwd rust -p bindings_napi --cargo-name bindings_napi', | ||
release: | ||
'napi build --platform --dts native.d.ts --js false --cargo-cwd rust -p bindings_napi --cargo-name bindings_napi --release' | ||
}, | ||
wasm: { | ||
dev: 'wasm-pack build rust/bindings_wasm --dev --out-dir ../../wasm --target web --no-pack', | ||
postBuild: 'shx rm wasm/.gitignore', | ||
release: 'wasm-pack build rust/bindings_wasm --out-dir ../../wasm --target web --no-pack' | ||
}, | ||
'wasm-node': { | ||
dev: 'wasm-pack build rust/bindings_wasm --dev --out-dir ../../wasm-node --target nodejs --no-pack', | ||
postBuild: 'shx rm wasm-node/.gitignore', | ||
release: | ||
'wasm-pack build rust/bindings_wasm --out-dir ../../wasm-node --target nodejs --no-pack' | ||
} | ||
}; | ||
|
||
const commandToRun = (() => { | ||
const buildCommand = buildCommands[binding][isRelease ? 'release' : 'dev']; | ||
const commandWithTarget = target ? `${buildCommand} --target ${target}` : buildCommand; | ||
const postBuild = buildCommands[binding].postBuild; | ||
return postBuild ? `${commandWithTarget} && ${postBuild}` : commandWithTarget; | ||
})(); | ||
|
||
console.log(` | ||
command to run: ${commandToRun} | ||
release or dev: ${isRelease ? 'release' : 'dev'} | ||
binding: ${binding} | ||
target: ${target} | ||
`); | ||
|
||
exec(commandToRun, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(error); | ||
exit(1); | ||
} | ||
|
||
console.log(stdout); | ||
console.error(stderr); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using
exec
, there is a nicerunWithEcho
helper inscripts/helpers.js
that has the advantage that it prints output while the command is running instead of waiting for the end. You would need to turn the arguments into an array, though, but it should make for a better experience when developing locally.Also, it promisifies the output, which means instead of a force exit, you can just top-level await the function so that errors will abort the script automatically with the full error.