From 6865b9899ea9632c9dbe8f83a025d9c1008613b8 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Mon, 21 Aug 2023 23:28:12 -0700 Subject: [PATCH] Tweak release workflow for more testing (#43) * Update README.md about publish * Updated workflow files --- .github/workflows/npm-publish-dev.yml | 25 +++++++++++++++++-------- .github/workflows/release.yml | 7 ++++--- README.md | 15 +++++---------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/.github/workflows/npm-publish-dev.yml b/.github/workflows/npm-publish-dev.yml index 12c7c23..a22bc16 100644 --- a/.github/workflows/npm-publish-dev.yml +++ b/.github/workflows/npm-publish-dev.yml @@ -1,10 +1,13 @@ name: Publish dev version on: - workflow_dispatch + workflow_run: + workflows: ["Publish dev version"] + types: + - manual jobs: - publish-dev-versions: + publish-dev-version: runs-on: ubuntu-latest steps: - name: 🤘 checkout @@ -22,11 +25,17 @@ jobs: - name: 🛠️ Build run: npm run build + - name: 🔐 Authenticate with NPM + run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTOMATION_TOKEN_CHRIS }}" > ~/.npmrc + - name: Publish packages to NPM with dev tag - id: changesets - uses: changesets/action@v1 - with: - publish: npm run changeset:publish-dev - env: - NPM_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN_CHRIS }} + run: | + for dir in packages/*; do + if [ -d "$dir" ]; then + echo "Publishing $dir package" + cd "$dir" + npm publish --tag dev + cd .. + fi + done diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c02b835..63bd96c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,8 +25,9 @@ jobs: run: npm ci --ignore-scripts - name: Create Release Pull Request - uses: changesets/action@v1 + uses: changesets/action@v2 with: - version: npm run changeset:version + title: Changeset Version Bump + commit: Update the version of packages with .changeset md files env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index 2124b01..dfe6578 100644 --- a/README.md +++ b/README.md @@ -98,15 +98,10 @@ npm run build The build command will generate distribution files under `packages/api-augment/build`. ## Publishing the Packages -Note: Only the @oak-network developer team on [npmjs.com](https://www.npmjs.com/) has the rights to publish new versions. - -Run the following command to publish the packages: - -```bash -npm run publish -- <2fa_code> -``` - -- The first parameter, ``, should match the OAK-blockchain code version. If the version string is like `1.9.0-rc.1`, it will be tagged with `rc` when uploaded to npm. -- The second parameter, `<2fa_code>`, is the Two-Factor Authenticator code of your npmjs.com account, which is enforced when joining the @oak-network team. +The release creation and publish is completely handled by Github Actions. +1. In order to trigger a version update, you need to run `npm run changeset` locally to generate a new version number and a Release Changelog. The script will create a .md file under .changeset like this PR, https://github.com/OAK-Foundation/oak.js/commit/c35050eb16bb73251fb05dd9010ab577f2adf5d6. +2. Once the above PR is merged to main, an Action will be triggered to update all package versions automatically, as seen in this PR, https://github.com/OAK-Foundation/oak.js/pull/42. +3. If things look good, merge the above PR created by changeset, and run the **Publish dev version** workflow manually to publish an NPM package version with `dev` tag for testing. +4. If testing goes well, run the **Make dev version latest** workflow manually to update the npm tag of `dev` to `latest`. You should receive an email from `support@npmjs.com` if the package is successfully published.