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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) => { | ||
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. Instead of using |
||
if (error) { | ||
console.error(error); | ||
exit(1); | ||
} | ||
|
||
console.log(stdout); | ||
console.error(stderr); | ||
}); |
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.
As test needs build, this should not be needed (but of course does not hurt, either)