Skip to content

Commit

Permalink
ci(release-automation): make release issuance atomic
Browse files Browse the repository at this point in the history
The NodeJS package publishing GitHub workflow job will now publish
all packages to both GHCR and npmjs.org registries.

It dynamically reconfigures the .npmrc file with the appropriate registry
URL and the correct token gets set through the environment variables as well.

The lerna publish script gets invoked twice, with different registry configurations
which was the only way I found to make sure that all the packages are deployed
to all the locations where they are to be used.

Fixes hyperledger-cacti#451

Signed-off-by: Peter Somogyvari <[email protected]>
  • Loading branch information
petermetz committed Sep 30, 2024
1 parent 499f703 commit 9c5b81e
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions .github/workflows/all-nodejs-packages-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,7 @@ jobs:
always-auth: true
node-version: ${{ env.NODEJS_VERSION }}
registry-url: "https://registry.npmjs.org/"

- run: cat /home/runner/work/_temp/.npmrc

- uses: actions/[email protected]
with:
always-auth: true
node-version: ${{ env.NODEJS_VERSION }}
registry-url: "https://npm.pkg.github.com/"

- run: cat /home/runner/work/_temp/.npmrc

- run: sed -i 's/npm.pkg.github.com\/:_authToken=${NODE_AUTH_TOKEN}/npm.pkg.github.com\/:_authToken=${GITHUB_TOKEN}/' /home/runner/work/_temp/.npmrc
scope: "@hyperledger"

- run: cat /home/runner/work/_temp/.npmrc

Expand All @@ -47,10 +36,36 @@ jobs:
JEST_TEST_RUNNER_DISABLED: true
TAPE_TEST_RUNNER_DISABLED: true

- name: lerna-publish
- name: lerna-publish-npm
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "hyperledger-ghci"
npm whoami
yarn lerna publish from-git --yes --loglevel=debug --ignore-scripts
- run: cat /home/runner/work/_temp/.npmrc

# Reset the .npmrc by deleting it. Invoking the setup-node action again below
# will set it up from scratch again but with a different registry configuration
# so that we can publish to both registries instead of having to choose.
- run: rm /home/runner/work/_temp/.npmrc

- uses: actions/[email protected]
with:
always-auth: true
node-version: ${{ env.NODEJS_VERSION }}
registry-url: "https://npm.pkg.github.com/"
scope: "@hyperledger"

- run: cat /home/runner/work/_temp/.npmrc

# We run the publish script a second time after having reconfigured the registry to be GHCR
# instead of npmjs.org so that we can publish the packages everywhere.
- name: lerna-publish-ghcr
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "hyperledger-ghci"
Expand Down

0 comments on commit 9c5b81e

Please sign in to comment.