Publish to npmjs #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |