From bcf04ce7053ad9b9329c5d1f57819533f335d4ad Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Wed, 1 May 2024 22:47:58 +0100 Subject: [PATCH] ci: separate publish workflow to ensure order (#2782) --- .github/workflows/publish.yml | 36 +++++++++++++++++++ .github/workflows/release.yml | 25 +++++-------- .github/workflows/snapshot.yml | 18 +--------- .github/workflows/test-published-packages.yml | 1 + 4 files changed, 47 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000000..a87bed145d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,36 @@ +name: Publish to npm + +on: + push: + branches: + - "main" + paths-ignore: + - "docs/**" + +# Ensure only one workflow/job is publishing to npm at a time +concurrency: publish-to-npm + +jobs: + release: + if: github.repository == 'latticexyz/mud' + uses: "./.github/workflows/release.yml" + secrets: inherit + + snapshot: + if: github.repository == 'latticexyz/mud' + needs: [release] + uses: "./.github/workflows/snapshot.yml" + secrets: inherit + + docker: + if: github.repository == 'latticexyz/mud' + needs: [release, snapshot] + uses: "./.github/workflows/docker.yml" + secrets: inherit + + test-snapshot: + if: github.repository == 'latticexyz/mud' + uses: ./.github/workflows/test-published-packages.yml + needs: [release, snapshot] + with: + tag-or-version: ${{ github.ref_name }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ba64aede6..0ef510c91c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,11 +1,7 @@ name: Release 🔖 on: - push: - branches: - - "main" - paths-ignore: - - "docs/**" + workflow_call: # Ensure only one workflow/job is publishing to npm at a time concurrency: publish-to-npm @@ -16,7 +12,6 @@ env: jobs: release: name: Release - if: github.repository == 'latticexyz/mud' runs-on: ubuntu-latest # Permissions necessary for Changesets to push a new branch and open PRs # (for automated Version Packages PRs), and request the JWT for provenance. @@ -31,20 +26,22 @@ jobs: with: submodules: recursive + - name: Check for pre.json file existence + id: check_files + uses: andstor/file-existence-action@v2.0.0 + with: + files: ".changeset/pre.json" + - name: "Setup" + if: steps.check_files.outputs.files_exists == 'false' uses: ./.github/actions/setup - name: Set deployment token + if: steps.check_files.outputs.files_exists == 'false' run: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Check for pre.json file existence - id: check_files - uses: andstor/file-existence-action@v2.0.0 - with: - files: ".changeset/pre.json" - - name: Create version PR or publish 🚀 if: steps.check_files.outputs.files_exists == 'false' uses: changesets/action@v1 @@ -53,7 +50,3 @@ jobs: version: pnpm release:version env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - docker: - uses: ./.github/workflows/docker.yml - needs: release diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index a1bbc284d7..1ca6dd28f6 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -1,14 +1,8 @@ name: Snapshot release -# Releases a snapshot release when new commits merge to main -# This ensures the release process is working as expected on: + workflow_call: workflow_dispatch: - push: - branches: - - main - paths-ignore: - - "docs/**" # Ensure only one workflow/job is publishing to npm at a time concurrency: publish-to-npm @@ -64,13 +58,3 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - docker: - uses: ./.github/workflows/docker.yml - needs: release-snapshot - - test-snapshot: - uses: ./.github/workflows/test-published-packages.yml - needs: release-snapshot - with: - tag-or-version: ${{ github.ref_name }} diff --git a/.github/workflows/test-published-packages.yml b/.github/workflows/test-published-packages.yml index 5ea68ffd75..95a40d8bea 100644 --- a/.github/workflows/test-published-packages.yml +++ b/.github/workflows/test-published-packages.yml @@ -11,6 +11,7 @@ on: tag-or-version: required: true type: string + description: npm tag or version of MUD jobs: test-create-mud-project: