diff --git a/.github/workflows/publish-merged-release.yml b/.github/workflows/publish-merged-release.yml index 19a427a..f61a8d2 100644 --- a/.github/workflows/publish-merged-release.yml +++ b/.github/workflows/publish-merged-release.yml @@ -1,6 +1,12 @@ name: Publish merged release on: + workflow_call: + inputs: + workflows-ref: + description: The github-workflows SHA this caller pins in `uses:`. Callers must set it. + required: false + type: string pull_request: branches: [main] types: [closed] @@ -17,6 +23,13 @@ jobs: with: ref: ${{ github.event.pull_request.merge_commit_sha }} fetch-depth: 0 + - name: Check out this workflow revision + uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5 + with: + repository: dilettacal/github-workflows + # github.workflow_sha is the caller's commit inside workflow_call. + ref: ${{ inputs.workflows-ref || github.workflow_sha }} + path: .shared-workflows - name: Publish tag and release env: GH_TOKEN: ${{ github.token }} @@ -25,8 +38,8 @@ jobs: set -euo pipefail version="${PR_TITLE#chore(release): }" version="${version%% *}" - python3 scripts/release.py validate-prepared --version "$version" + python3 .shared-workflows/scripts/release.py validate-prepared --version "$version" git tag "v$version" git push origin "v$version" - python3 scripts/release.py release-notes --version "$version" > release-notes.md + python3 .shared-workflows/scripts/release.py release-notes --version "$version" > release-notes.md gh release create "v$version" --title "v$version" --notes-file release-notes.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 386f162..492b381 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to these reusable GitHub Actions workflows are recorded here ## [Unreleased] +### Added + +- Reusable `publish-merged-release.yml` so consumer repositories publish the tag and GitHub Release when the release PR merges, without a second dispatch. + ## [0.1.1] - 2026-10-31 ### Fixed diff --git a/README.md b/README.md index 3b5e077..4fafbee 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,20 @@ Shared GitHub Actions policy and release workflows, maintained once and pinned b | Workflow | Purpose | | --- | --- | | `pull-request-policy.yml` | Checks Conventional Commit-style PR titles and requires a changed `CHANGELOG.md` for releasable work. | -| `publish-release.yml` | Prepares a versioned release PR, then publishes the tag and GitHub Release after that PR merges. | +| `publish-release.yml` | Prepares a versioned release PR. | +| `publish-merged-release.yml` | Publishes the tag and GitHub Release when a `chore(release): X.Y.Z` PR merges. | ## Use Copy a caller from [`examples/`](examples/), pin ``, and keep the caller responsible for events, permissions, checks, and branch protection. -Release callers pass the same SHA as `workflows-ref`: inside `workflow_call`, +Release and publish callers pass the same SHA as `workflows-ref`: inside `workflow_call`, `github.workflow_sha` is the caller's commit, not this repository's. -Release callers dispatch `X.Y.Z`: first run opens a release PR; after merging -it, run the same version again to publish the tag and GitHub Release. +Release callers dispatch `X.Y.Z` once to open a release PR. With the +`publish-merged-release.yml` caller, merging that PR publishes the tag and +GitHub Release. Without it, dispatch the same version again after merging. ## Development diff --git a/examples/publish-merged-release.yml b/examples/publish-merged-release.yml new file mode 100644 index 0000000..d698ba2 --- /dev/null +++ b/examples/publish-merged-release.yml @@ -0,0 +1,15 @@ +name: Publish merged release + +on: + pull_request: + branches: [main] + types: [closed] + +permissions: + contents: write + +jobs: + publish: + uses: dilettacal/github-workflows/.github/workflows/publish-merged-release.yml@ + with: + workflows-ref: