Skip to content

Commit f5ffd00

Browse files
committed
ci: auto-publish on release by calling publish.yml as a reusable workflow
release.yml created the GitHub Release with GITHUB_TOKEN, whose events don't trigger other workflows — so publish.yml's 'release: published' trigger never fired and npm was never published. Make release.yml call publish.yml directly (workflow_call + secrets: inherit) after cutting the tag/release, gated on a version change. A direct reusable-workflow call isn't subject to the GITHUB_TOKEN recursion guard, so a version bump on main now auto-publishes — no manual dispatch, no PAT secret. publish.yml keeps its release/dispatch triggers for manual runs.
1 parent 1fc757b commit f5ffd00

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ name: Publish to npm
33
on:
44
release:
55
types: [published]
6+
# Called directly by release.yml after it cuts the tag/release. A reusable
7+
# workflow_call is a direct invocation, so it runs even though the release
8+
# was created with GITHUB_TOKEN (whose events don't trigger other workflows).
9+
workflow_call:
10+
inputs:
11+
dry-run:
12+
description: 'Dry run (skip actual publish)'
13+
type: boolean
14+
default: false
615
workflow_dispatch:
716
inputs:
817
dry-run:

.github/workflows/release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
99
runs-on: ubuntu-latest
1010
permissions:
1111
contents: write
12+
outputs:
13+
changed: ${{ steps.version.outputs.changed }}
14+
version: ${{ steps.version.outputs.version }}
1215
steps:
1316
- uses: actions/checkout@v4
1417
with:
@@ -41,3 +44,13 @@ jobs:
4144
gh release create "$TAG" \
4245
--title "$TAG" \
4346
--generate-notes
47+
48+
# Publish straight after the release is cut. Called as a reusable workflow
49+
# (not via the `release: published` event, which GITHUB_TOKEN-created releases
50+
# never fire) so a version bump on main now auto-publishes to npm with no
51+
# manual dispatch and no PAT. Skipped when the version didn't change.
52+
publish:
53+
needs: release
54+
if: needs.release.outputs.changed == 'true'
55+
uses: ./.github/workflows/publish.yml
56+
secrets: inherit

0 commit comments

Comments
 (0)