Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 39 additions & 7 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
name: Node.js Package

run-name: ${{ github.event_name == 'workflow_dispatch' && format('Dry run publish {0}', inputs.version) || format('Publish {0}', github.event.release.tag_name) }}

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Version to rehearse, with or without v prefix. Example: 12.0.1"
required: true
type: string

jobs:
publish:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
with:
ref: main
ref: ${{ github.event_name == 'release' && 'main' || github.ref }}

- uses: actions/setup-node@v4
with:
Expand All @@ -22,11 +30,27 @@ jobs:
git config user.name github-actions
git config user.email github-actions@github.com

- name: Update versions
- name: Resolve version
id: version
env:
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
VERSION_INPUT: ${{ inputs.version }}
run: |
TAG="${{ github.event.release.tag_name }}"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="$VERSION_INPUT"
else
TAG="$RELEASE_TAG_NAME"
fi

VERSION="${TAG#v}"
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Update versions
env:
TAG: ${{ steps.version.outputs.tag }}
VERSION: ${{ steps.version.outputs.version }}
run: |
npm version "$VERSION" --ws --allow-same-version --no-git-tag-version

for module in packages/modules/*; do
Expand All @@ -42,12 +66,20 @@ jobs:
npm ci
npm run build --ws

- name: Git commit and push
run: |
git commit -am "${{ github.event.release.tag_name }}"
git push
- name: Git commit
if: ${{ github.event_name == 'release' }}
run: git commit -am "${{ steps.version.outputs.tag }}"
Comment thread
cristianrgreco marked this conversation as resolved.

- name: Git push
if: ${{ github.event_name == 'release' }}
run: git push

- name: Dry run publish
if: ${{ github.event_name == 'workflow_dispatch' }}
run: npm publish --ws --dry-run

- name: Publish packages to NPM
if: ${{ github.event_name == 'release' }}
run: npm publish --ws
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
Loading