Skip to content

Commit 1dc615a

Browse files
authored
Merge pull request #36 from hack-dance/codex/fix-release-workflow-dispatch
fix: dispatch releases explicitly after tagging
2 parents 1b51795 + 7bcbed8 commit 1dc615a

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
tags:
66
- "v*"
77
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: Tag to release, for example v1.2.3
11+
required: false
812

913
permissions:
1014
contents: write
@@ -16,6 +20,7 @@ jobs:
1620
- uses: actions/checkout@v4
1721
with:
1822
fetch-depth: 0
23+
ref: ${{ github.event.inputs.tag || github.ref }}
1924
- uses: actions/setup-go@v5
2025
with:
2126
go-version-file: go.mod

.github/workflows/tag-release.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717
required: false
1818

1919
permissions:
20+
actions: write
2021
contents: write
2122
issues: write
2223
pull-requests: write
@@ -51,23 +52,37 @@ jobs:
5152
echo "version=$version" >> "$GITHUB_OUTPUT"
5253
5354
- name: Create tag if missing
55+
id: create_tag
5456
env:
5557
PUSH_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN || github.token }}
5658
TARGET_SHA: ${{ github.event.inputs.sha || github.event.pull_request.merge_commit_sha || github.sha }}
5759
run: |
5860
tag="v${{ steps.version.outputs.version }}"
61+
created="false"
5962
6063
git fetch --tags origin
6164
if git rev-parse "$tag" >/dev/null 2>&1; then
6265
echo "tag $tag already exists"
63-
exit 0
66+
else
67+
git config user.name "github-actions[bot]"
68+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
69+
git remote set-url origin "https://x-access-token:${PUSH_TOKEN}@github.com/${{ github.repository }}.git"
70+
git tag "$tag" "$TARGET_SHA"
71+
git push origin "$tag"
72+
created="true"
6473
fi
6574
66-
git config user.name "github-actions[bot]"
67-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
68-
git remote set-url origin "https://x-access-token:${PUSH_TOKEN}@github.com/${{ github.repository }}.git"
69-
git tag "$tag" "$TARGET_SHA"
70-
git push origin "$tag"
75+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
76+
echo "created=$created" >> "$GITHUB_OUTPUT"
77+
78+
- name: Dispatch release workflow
79+
if: steps.create_tag.outputs.created == 'true'
80+
env:
81+
GH_TOKEN: ${{ github.token }}
82+
run: |
83+
gh workflow run release.yml \
84+
--ref main \
85+
-f tag="${{ steps.create_tag.outputs.tag }}"
7186
7287
- name: Mark release PR as tagged
7388
if: github.event_name == 'pull_request_target' || github.event.inputs.pr_number != ''

docs/releasing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This repo uses conventional commits on `main` plus `release-please` and
1111
parseable release commits.
1212
- `release-please` watches `main`, opens a release PR, updates `CHANGELOG.md`, and bumps the version manifest.
1313
- Merging the release PR triggers `tag-release`, which creates the Git tag from the merged release commit.
14-
- Tag pushes trigger `goreleaser`, which builds artifacts, creates the GitHub Release, and updates `hack-dance/homebrew-tap`.
14+
- `tag-release` then dispatches the `release` workflow for that tag so `goreleaser` builds artifacts, creates the GitHub Release, and updates `hack-dance/homebrew-tap`.
1515

1616
## Required secrets
1717

@@ -27,7 +27,7 @@ This repo uses conventional commits on `main` plus `release-please` and
2727
3. Review the generated version and changelog.
2828
4. Merge the release PR.
2929
5. Verify `tag-release` pushed the expected `vX.Y.Z` tag.
30-
6. Verify the `release` workflow published artifacts and updated the Homebrew tap.
30+
6. Verify the dispatched `release` workflow published artifacts and updated the Homebrew tap.
3131

3232
## Local dry run
3333

0 commit comments

Comments
 (0)