Skip to content

Commit

Permalink
ci: separate publish workflow to ensure order (#2782)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored May 1, 2024
1 parent 98fbbd2 commit bcf04ce
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 33 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
25 changes: 9 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand All @@ -31,20 +26,22 @@ jobs:
with:
submodules: recursive

- name: Check for pre.json file existence
id: check_files
uses: andstor/[email protected]
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/[email protected]
with:
files: ".changeset/pre.json"

- name: Create version PR or publish 🚀
if: steps.check_files.outputs.files_exists == 'false'
uses: changesets/action@v1
Expand All @@ -53,7 +50,3 @@ jobs:
version: pnpm release:version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docker:
uses: ./.github/workflows/docker.yml
needs: release
18 changes: 1 addition & 17 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions .github/workflows/test-published-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
tag-or-version:
required: true
type: string
description: npm tag or version of MUD

jobs:
test-create-mud-project:
Expand Down

0 comments on commit bcf04ce

Please sign in to comment.