Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 19 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
name: Publish Package

on:
# Direct trigger used by the release workflow (and available manually).
# The release workflow cannot rely on the `release` event below: releases
# created with the default GITHUB_TOKEN do not trigger other workflows.
workflow_dispatch:
inputs:
tag:
description: 'Git tag to publish (e.g. v0.2.12)'
required: true
type: string
# Still fires for releases created manually in the GitHub UI or with a PAT.
release:
types: [published]

permissions:
contents: read
# Required for npm trusted publishing (OIDC) and provenance.
id-token: write

jobs:
publish:
if: startsWith(github.event.release.tag_name, 'v')
if: startsWith(inputs.tag || github.event.release.tag_name, 'v')
runs-on: ubuntu-latest

steps:
- name: Checkout repository (fetch all tags)
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Resolve tag to publish
id: tag
run: |
echo "tag=${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT"
echo "tag=${{ inputs.tag || github.event.release.tag_name }}" >>"$GITHUB_OUTPUT"

- name: Checkout repository at the release tag
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ steps.tag.outputs.tag }}

- name: Setup Node.js
uses: actions/setup-node@v6
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:

permissions:
contents: write
# Needed to dispatch the publish workflow at the end of the release job.
actions: write

jobs:
release:
Expand Down Expand Up @@ -74,3 +76,13 @@ jobs:
else
gh release create "$TAG" --title "$TAG" --notes-file RELEASE_NOTES.md
fi

# Releases created with the default GITHUB_TOKEN do not trigger the
# `release: published` event in other workflows (GitHub's recursion
# guard), so the publish workflow must be dispatched explicitly.
# workflow_dispatch is exempt from that guard.
- name: Trigger npm publish workflow
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.release.outputs.tag }}
run: gh workflow run publish.yml --ref main -f tag="$TAG"
Loading