diff --git a/common/web/keyman-version/.npmignore b/common/web/keyman-version/.npmignore new file mode 100644 index 00000000000..c22b1d82230 --- /dev/null +++ b/common/web/keyman-version/.npmignore @@ -0,0 +1,5 @@ +build/index.tsbuildinfo +build/tsconfig.esm.tsbuildinfo +build.sh +index.ts +tsconfig.json \ No newline at end of file diff --git a/common/web/keyman-version/build.sh b/common/web/keyman-version/build.sh index 370c33ee880..31774b007be 100755 --- a/common/web/keyman-version/build.sh +++ b/common/web/keyman-version/build.sh @@ -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" \ @@ -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 diff --git a/developer/src/kmlmc/.npmignore b/developer/src/kmlmc/.npmignore index 73126b73384..2ac029d741a 100644 --- a/developer/src/kmlmc/.npmignore +++ b/developer/src/kmlmc/.npmignore @@ -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 diff --git a/developer/src/kmlmc/build.sh b/developer/src/kmlmc/build.sh index 9d229e11952..4b48d7bf9df 100755 --- a/developer/src/kmlmc/build.sh +++ b/developer/src/kmlmc/build.sh @@ -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 diff --git a/resources/build/build-utils-ci.inc.sh b/resources/build/build-utils-ci.inc.sh index 6212f9720c0..75f6c8f6a52 100644 --- a/resources/build/build-utils-ci.inc.sh +++ b/resources/build/build-utils-ci.inc.sh @@ -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 +}