Closed mate-from-mattr closed 2 years ago
publish:binary
as it currently works. Note how an error results in the script completing "successfully", and with zero status code ($?
):
$ yarn publish:binary
yarn run v1.22.19
$ ./scripts/publish_binary.sh
$ node-pre-gyp package
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@1.0.9
node-pre-gyp info using node@14.19.3 | darwin | x64
packing native/index.node
node-pre-gyp info package Binary staged at "build/stage/0.15.0/node-v83-darwin-x64.tar.gz"
node-pre-gyp info ok
(node:51661) UnhandledPromiseRejectionWarning: Error: NODE_PRE_GYP_GITHUB_TOKEN environment variable not found
at Object.publish (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/@mathquis/node-pre-gyp-github/index.js:26:13)
at Command.<anonymous> (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/@mathquis/node-pre-gyp-github/bin/node-pre-gyp-github.js:15:10)
at Command.listener [as _actionHandler] (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/commander/index.js:922:31)
at Command._parseCommand (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/commander/index.js:1503:14)
at Command._dispatchSubcommand (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/commander/index.js:1443:18)
at Command._parseCommand (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/commander/index.js:1460:12)
at Command.parse (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/commander/index.js:1292:10)
at Object.<anonymous> (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/@mathquis/node-pre-gyp-github/bin/node-pre-gyp-github.js:27:9)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:51661) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:51661) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨ Done in 1.92s.
Mates-MacBook-Pro:node-bbs-signatures mate.antunovic$ echo $?
0
publish:binary
after applying the changes in this PR:
$ yarn publish:binary
yarn run v1.22.19
$ ./scripts/publish_binary.sh
$ node-pre-gyp package
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@1.0.9
node-pre-gyp info using node@14.19.3 | darwin | x64
packing native/index.node
node-pre-gyp info package Binary staged at "build/stage/0.15.0/node-v83-darwin-x64.tar.gz"
node-pre-gyp info ok
/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/@mathquis/node-pre-gyp-github/index.js:26
throw new Error('NODE_PRE_GYP_GITHUB_TOKEN environment variable not found')
^
Error: NODE_PRE_GYP_GITHUB_TOKEN environment variable not found
at Object.publish (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/@mathquis/node-pre-gyp-github/index.js:26:13)
at Command.<anonymous> (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/@mathquis/node-pre-gyp-github/bin/node-pre-gyp-github.js:15:10)
at Command.listener [as _actionHandler] (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/commander/index.js:922:31)
at Command._parseCommand (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/commander/index.js:1503:14)
at Command._dispatchSubcommand (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/commander/index.js:1443:18)
at Command._parseCommand (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/commander/index.js:1460:12)
at Command.parse (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/commander/index.js:1292:10)
at Object.<anonymous> (/Users/mate.antunovic/Dev/bbs/node-bbs-signatures/node_modules/@mathquis/node-pre-gyp-github/bin/node-pre-gyp-github.js:27:9)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ echo $?
1
Changes how
node-pre-gyp-github
is called so that if errors occur, they will bubble up. Also addsset -e
which tells the Bash scripts to exit if any command fails.Description
By default Bash scripts continue to run even if one command fails. Releasing is made up of many steps but is usually considered an atomic operation. By adding
set -e
the GitHub action will tell us if there was a problem releasing, which we want to know.Motivation and Context
This action was marked successful, but it caused problems for people who were wondering why master did not release.
Does this PR introduce a breaking change?
Which merge strategy will you use?