Skip to content

Commit

Permalink
ci: split publish into separate workflow file
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hm committed Aug 2, 2024
1 parent 931db06 commit 86a7d5f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Check, test, publish workflow

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
name: Check, build and test

on:
pull_request:
branches:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -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
42 changes: 42 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 86a7d5f

Please sign in to comment.