From 86a7d5ff1f24b76927290f53cafd591cc1239ca6 Mon Sep 17 00:00:00 2001 From: Tim Holmes-Mitra Date: Fri, 2 Aug 2024 11:21:20 -0400 Subject: [PATCH] ci: split publish into separate workflow file --- ...est-publish.yaml => check-build-test.yaml} | 44 +++---------------- .github/workflows/publish.yaml | 42 ++++++++++++++++++ 2 files changed, 47 insertions(+), 39 deletions(-) rename .github/workflows/{check-test-publish.yaml => check-build-test.yaml} (54%) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/check-test-publish.yaml b/.github/workflows/check-build-test.yaml similarity index 54% rename from .github/workflows/check-test-publish.yaml rename to .github/workflows/check-build-test.yaml index e340f1a..de5b2e4 100644 --- a/.github/workflows/check-test-publish.yaml +++ b/.github/workflows/check-build-test.yaml @@ -1,8 +1,4 @@ -name: Check, test, publish workflow - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true +name: Check, build and test on: pull_request: @@ -10,6 +6,10 @@ on: - main workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: check: runs-on: ubuntu-latest @@ -57,37 +57,3 @@ jobs: - run: | npm ci just test-${{ matrix.package }} - - publish: - needs: [ check, build-and-test ] - if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - strategy: - matrix: - package: [ client-wasm, client-core, client-payments, client-vms, client-react-hooks ] - steps: - - uses: actions/checkout@v4 - - uses: extractions/setup-just@v2 - - uses: actions/setup-node@v4 - with: - node-version: '22' - registry-url: "https://registry.npmjs.org" - - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.OS }}-node- - - env: - NODE_AUTH_TOKEN: - ${{ secrets.NPM_TOKEN }} - run: | - npm ci - VERSION=$(node -p "require('./packages/${{ matrix.package }}/package.json').version") - if [[ "$VERSION" =~ -rc.[0-9]+$ ]]; then - TAG="next" - else - TAG="latest" - fi - echo "Publishing version $VERSION with tag $TAG..." - just publish-${{ matrix.package }} "--tag ${TAG}" # should fail because this version is already published diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..931178a --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,42 @@ +name: Publish packages to npmjs + +on: + workflow_dispatch: + +concurrency: + group: "publish" + cancel-in-progress: true + +jobs: + publish: + if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + strategy: + matrix: + package: [ client-wasm, client-core, client-payments, client-vms, client-react-hooks ] + steps: + - uses: actions/checkout@v4 + - uses: extractions/setup-just@v2 + - uses: actions/setup-node@v4 + with: + node-version: '22' + registry-url: "https://registry.npmjs.org" + - uses: actions/cache@v3 + with: + path: ~/.npm + key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.OS }}-node- + - env: + NODE_AUTH_TOKEN: + ${{ secrets.NPM_TOKEN }} + run: | + npm ci + VERSION=$(node -p "require('./packages/${{ matrix.package }}/package.json').version") + if [[ "$VERSION" =~ -rc.[0-9]+$ ]]; then + TAG="next" + else + TAG="latest" + fi + echo "Publishing version $VERSION with tag $TAG..." + just publish-${{ matrix.package }} "--tag ${TAG}" # should fail because this version is already published