From 78c8308d8b7c7bf09d03a12e40de9454debb1a09 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Wed, 23 Aug 2023 23:11:22 -0700 Subject: [PATCH] Fixed multi-package issue in both npm-publish-dev and update-package-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 --- .github/workflows/npm-publish-dev.yml | 21 ++++++----- .github/workflows/update-package-tags.yml | 44 ++++++++--------------- 2 files changed, 25 insertions(+), 40 deletions(-) diff --git a/.github/workflows/npm-publish-dev.yml b/.github/workflows/npm-publish-dev.yml index 64617f2..a79a222 100644 --- a/.github/workflows/npm-publish-dev.yml +++ b/.github/workflows/npm-publish-dev.yml @@ -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 @@ -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 diff --git a/.github/workflows/update-package-tags.yml b/.github/workflows/update-package-tags.yml index 5fd9875..3914b07 100644 --- a/.github/workflows/update-package-tags.yml +++ b/.github/workflows/update-package-tags.yml @@ -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 @@ -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/setup-node@v3.0.0 - 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."