From 5fde2ae0a8eea19c23bc5ae261083c9eef4e3b00 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 23 Jun 2022 22:51:43 -0700 Subject: [PATCH] Add continuous deployment to npm (#2776) --- .circleci/config.yml | 7 ++++++- docs/development/maintainers.md | 25 +++---------------------- tools/deploy_to_npm.sh | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 23 deletions(-) create mode 100755 tools/deploy_to_npm.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index a4258bc76..5a14ba64b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -282,7 +282,7 @@ jobs: - run: name: Install requirements command: | - apk add --no-cache --update python3 make + apk add --no-cache --update python3 make npm python3 -m pip install awscli - run: name: Deploy Github Releases @@ -292,6 +292,11 @@ jobs: tar cjf pyodide-build-${CIRCLE_TAG}.tar.bz2 pyodide/ ghr -t "${GITHUB_TOKEN}" -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" -c "${CIRCLE_SHA1}" -delete "${CIRCLE_TAG}" ./pyodide-build-${CIRCLE_TAG}.tar.bz2 + - run: + name: Deploy to npm + command: | + ./tools/deploy_to_npm.sh + - run: name: Set PYODIDE_BASE_URL command: PYODIDE_BASE_URL="https://cdn.jsdelivr.net/pyodide/v${CIRCLE_TAG}/full/" make update_base_url diff --git a/docs/development/maintainers.md b/docs/development/maintainers.md index 542f234ac..aac83a223 100644 --- a/docs/development/maintainers.md +++ b/docs/development/maintainers.md @@ -65,27 +65,15 @@ the latest release branch named `stable` (due to ReadTheDocs constraints). git push upstream stable --force ``` -7. Release the Pyodide JavaScript package: - - ```bash - make clean && PYODIDE_PACKAGES="*" make - cd dist - # If making a major/minor release: - npm publish - npm dist-tag add pyodide@a.b.c next # Label this release as also the latest unstable release - # If making an alpha release: - npm publish --tag next - ``` - -8. Revert the release commit. If making major release, increment the version to - the next development version specified by Semantic Versioning. +7. Revert the release commit. If making a major release, increment the version + to the next development version specified by Semantic Versioning. ```sh # If you just released 0.22.0, then set the next version to 0.23.0 ./tools/bump_version.py --new-version 0.23.0.dev0 ``` -9. Update these instructions with any relevant changes. +8. Update these instructions with any relevant changes. ### Making a minor release @@ -116,13 +104,6 @@ Then follow the relevant steps from {ref}`release-instructions`. Name the first alpha release `x.x.xa1` and in subsequent alphas increment the final number. Follow the relevant steps from {ref}`release-instructions`. -For the node package make sure to use `npm publish --tag next` to avoid setting -the alpha version as the stable release. If you accidentally publish the alpha -release over the stable `latest` tag, you can fix it with: -`npm dist-tag add pyodide@a.b.c latest` where `a.b.c` should be the latest -stable version. Then use `npm dist-tag add pyodide@a.b.c-alpha.d next` to set -the `next` tag to point to the just-published alpha release. - ### Fixing documentation for a released version Cherry pick the corresponding documentation commits to the `stable` branch. Use diff --git a/tools/deploy_to_npm.sh b/tools/deploy_to_npm.sh new file mode 100755 index 000000000..d7e864f65 --- /dev/null +++ b/tools/deploy_to_npm.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -e + +echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc +cd dist/ + +PACKAGE_NAME=$(node -p "require('./package.json').name") +JS_VERSION=$(node -p "require('./package.json').version") +if [[ ${JS_VERSION} =~ [alpha|beta|rc|dev] ]]; then + echo "Publishing an unstable release" + npm publish --tag next +else + echo "Publishing a stable release" + npm publish + npm dist-tag add "$PACKAGE_NAME"@"$JS_VERSION" next +fi