mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-05 00:15:32 +00:00
Due to recent changes in NPM package publishing security requirements, we have to move from TeamCity build to a GitHub Action to publish our NPM packages, so we can take advantage of trusted publishing. This change also consolidates and centralizes the npm publishing into resources/build/ci/npm-publish.sh, which removes a lot of boilerplate from each of the build.sh scripts, and ensures consistency. Packages will be `npm pack`ed on PR and test builds, and published in release builds. Ref: https://docs.npmjs.com/trusted-publishers Ref: https://github.blog/changelog/2025-09-29-strengthening-npm-security-important-changes-to-authentication-and-token-management/ Fixes: #14963 Test-bot: skip Build-bot: release:developer
59 lines
2 KiB
Bash
Executable file
59 lines
2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# Keyman is copyright (C) SIL Global. MIT License.
|
|
#
|
|
# Publish all the @keymanapp packages listed in npm-packages.inc.sh
|
|
#
|
|
# If the `--dry-run` option is available and specified as a command-line
|
|
# parameter, will do a dry run
|
|
#
|
|
# Note that `package.json` will be dirty after this command, as the `version`
|
|
# field will be added to it, and @keymanapp dependency versions will also be
|
|
# modified. This change should not be committed to the repository.
|
|
#
|
|
# If `publish` is called:
|
|
# * then ci_publish_npm publishes to the public registry
|
|
# * else ci_publish_npm creates a local tarball which can be used to test
|
|
#
|
|
## START STANDARD BUILD SCRIPT INCLUDE
|
|
# adjust relative paths as necessary
|
|
THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
|
|
. "${THIS_SCRIPT%/*}/../../../resources/build/builder-full.inc.sh"
|
|
## END STANDARD BUILD SCRIPT INCLUDE
|
|
|
|
. "$KEYMAN_ROOT/resources/build/ci/ci-publish.inc.sh"
|
|
. "$KEYMAN_ROOT/resources/build/ci/npm-packages.inc.sh"
|
|
|
|
builder_describe \
|
|
"Publish @keymanapp packages to NPM" \
|
|
"pack Pack NPM packages to a .tgz for verification" \
|
|
"publish Publish NPM packages to the NPM Registry" \
|
|
"--dry-run Don't publish/pack anything, just dry run"
|
|
|
|
builder_parse "$@"
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------
|
|
|
|
function do_pack() {
|
|
local npm_package_path
|
|
for npm_package_path in "${PACKAGES[@]}"; do
|
|
builder_heading "Packing $npm_package_path"
|
|
ci_publish_npm_package pack "$npm_package_path"
|
|
done
|
|
}
|
|
|
|
function do_publish() {
|
|
local npm_package_path
|
|
|
|
if [[ $KEYMAN_VERSION_ENVIRONMENT =~ local|test ]] && ! builder_has_option --dry-run; then
|
|
builder_die "publish must use --dry-run flag for local or test builds"
|
|
fi
|
|
|
|
for npm_package_path in "${PACKAGES[@]}"; do
|
|
builder_heading "Publishing $npm_package_path"
|
|
ci_publish_npm_package publish "$npm_package_path"
|
|
done
|
|
}
|
|
|
|
builder_run_action pack do_pack
|
|
builder_run_action publish do_publish
|