Skip to content

Commit

Permalink
Fixed multi-package issue in both npm-publish-dev and update-package-…
Browse files Browse the repository at this point in the history
…tags workflows (#62)

* Experiment with workflow strategy

* Fixed the indention of workflow

* Updated set dev to latest tag workflow with strategy

* Fixed syntax of set dev to latest tag workflow

* Fixed syntax of set dev to latest tag workflow
  • Loading branch information
chrisli30 authored Aug 24, 2023
1 parent 77408d2 commit 78c8308
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 40 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/npm-publish-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ on:
jobs:
publish-dev-version:
runs-on: ubuntu-latest
strategy:
matrix:
package:
# List the packages to run here. The matrix will run one job for each package parallelly.
- api-augment
- types

steps:
- name: 🤘 checkout
uses: actions/checkout@v3
Expand All @@ -34,14 +41,6 @@ jobs:
- name: 🔐 Authenticate with NPM
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTOMATION_TOKEN_CHRIS }}" > ~/.npmrc

- name: Loop through Package Names
id: loop-package-names
run: |
for package in ${{ steps.set_package_names.outputs.packages }}; do
echo "Processing package: $package"
npm publish --tag dev "packages/$package"
done
- name: Use loop outputs
run: |
echo "Loop completed."
- name: 🚀 Publish ${{ matrix.package }} package
working-directory: ./packages/${{ matrix.package }}
run: npm publish --tag dev
44 changes: 15 additions & 29 deletions .github/workflows/update-package-tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
jobs:
update-tags:
runs-on: ubuntu-latest
strategy:
matrix:
package:
# List the packages to run here. The matrix will run one job for each package parallelly.
- api-augment
- types

steps:
- name: Checkout repository
Expand All @@ -17,36 +23,16 @@ jobs:
- name: 🔐 Authenticate with NPM
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTOMATION_TOKEN_CHRIS }}" > ~/.npmrc

- name: Set package names
id: set_package_names
- name: Get dev version of ${{ matrix.package }}
id: get-version
run: |
echo '["@oak-network/api-augment", "@oak-network/types"]' > packages.json
- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: 18.x
cache: 'npm'

- name: Loop through Package Names
id: loop-package-names
dev_version=$(npm show @oak-network/${{ matrix.package }}@dev version)
echo "Dev version: $dev_version"
echo "::set-output name=dev_version::$dev_version"
- name: Point latest tag to ${{ steps.get-version.outputs.dev_version }}
run: |
packages=$(cat packages.json)
for package in $packages; do
echo "Processing package: $package"
# Get dev version
dev_version=$(npm show $package@dev version)
echo "Dev version: $dev_version"
# Set latest tag
npm dist-tag add $package@$dev_version latest --registry=https://registry.npmjs.org/
echo "Latest tag set to $dev_version"
done
npm dist-tag add @oak-network/${{ matrix.package }}@${{ steps.get-version.outputs.dev_version }} latest --registry=https://registry.npmjs.org/
echo "Latest tag set to ${{ steps.get-version.outputs.dev_version }}"
env:
NPM_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN_CHRIS }}

- name: Use loop outputs
run: |
echo "Loop completed."

0 comments on commit 78c8308

Please sign in to comment.