Skip to content
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

fix(developer): publish @keymanapp/keyman-version to npm #7595

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions common/web/keyman-version/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build/index.tsbuildinfo
build/tsconfig.esm.tsbuildinfo
build.sh
index.ts
tsconfig.json
13 changes: 12 additions & 1 deletion common/web/keyman-version/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ cd "$THIS_SCRIPT_PATH"

################################ Main script ################################

builder_describe "Build the include script for current Keyman version" configure clean build
builder_describe "Build the include script for current Keyman version" \
configure \
clean \
build \
publish \
--dry-run

builder_describe_outputs \
configure "/node_modules" \
Expand Down Expand Up @@ -68,3 +73,9 @@ if builder_start_action build; then

builder_finish_action success build
fi

if builder_start_action publish; then
. "$KEYMAN_ROOT/resources/build/build-utils-ci.inc.sh"
builder_publish_to_npm
builder_finish_action success publish
fi
7 changes: 5 additions & 2 deletions developer/src/kmlmc/.npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Ignore files required only in development.
build.sh
bundle.sh
dist-tests/*
source/*
tests/*
build.sh
bundle.sh
Makefile
tsconfig.json
tsconfig.tsbuildinfo
5 changes: 5 additions & 0 deletions developer/src/kmlmc/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,9 @@ if (( should_publish )); then
# See `npm help publish` for more details.
echo "Publishing $DRY_RUN npm package with tag $npm_dist_tag"
npm publish $DRY_RUN --access public --tag $npm_dist_tag || fail "Could not publish $npm_dist_tag release."

# For now, kmlmc will have responsibility for publishing keyman-version. In
# the future, we should probably have a top-level npm publish script that
# publishes all modules for a given release version
"$KEYMAN_ROOT/common/web/keyman-version/build.sh" publish $DRY_RUN
fi
41 changes: 41 additions & 0 deletions resources/build/build-utils-ci.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,44 @@ function builder_pull_has_label() {
fi
return 1
}

#
# Publishes the package in `cwd` to npm
#
# 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. This change should not be committed to the
# repository.
#
# Usage:
# ```bash
# builder_publish_to_npm
# ```
#
function builder_publish_to_npm() {
local dist_tag=$TIER dry_run

if [[ $TIER == stable ]]; then
dist_tag=latest
fi

if builder_has_option --dry-run; then
dry_run=--dry-run
fi

# We use --no-git-tag-version because our CI system controls version numbering and
# already tags releases. We also want to have the version of this match the
# release of Keyman Developer -- these two versions should be in sync. Because this
# is a large repo with multiple projects and build systems, it's better for us that
# individual build systems don't take too much ownership of git tagging. :)
npm version --allow-same-version --no-git-tag-version --no-commit-hooks "$VERSION_WITH_TAG"

# Note: In either case, npm publish MUST be given --access public to publish
# a package in the @keymanapp scope on the public npm package index.
#
# See `npm help publish` for more details.
echo "Publishing $dry_run npm package $THIS_SCRIPT_IDENTIFIER with tag $dist_tag"
npm publish $dry_run --access public --tag $dist_tag
}