Skip to content

Commit a25a31b

Browse files
committed
Fix release workflow triggering for automated tags
Add workflow_dispatch trigger to release.yml to work around GitHub's limitation where GITHUB_TOKEN doesn't trigger workflows on tag push. The manage-release-tags workflow now explicitly triggers the release workflow after creating tags using gh workflow run.
1 parent fa2b4f4 commit a25a31b

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

.github/workflows/manage-release-tags.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88

99
permissions:
1010
contents: write
11+
actions: write
1112

1213
jobs:
1314
create-tags:
@@ -27,6 +28,8 @@ jobs:
2728
2829
- name: Handle initial release tag
2930
if: github.event_name == 'create' && github.event.ref_type == 'branch'
31+
env:
32+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3033
run: |
3134
BRANCH_NAME="${{ github.event.ref }}"
3235
@@ -50,8 +53,13 @@ jobs:
5053
git tag "$TAG"
5154
git push origin "$TAG"
5255
56+
echo "Triggering release workflow for $TAG"
57+
gh workflow run release.yml -f tag="$TAG"
58+
5359
- name: Handle patch release tags
5460
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
61+
env:
62+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5563
run: |
5664
# Find all release branches
5765
RELEASE_BRANCHES=$(git branch -r | grep -E 'origin/release-[0-9]+\.[0-9]+$' | sed 's|origin/||' | sed 's/^[[:space:]]*//')
@@ -114,4 +122,8 @@ jobs:
114122
git push origin "$NEW_TAG"
115123
116124
echo "Successfully created and pushed tag $NEW_TAG"
125+
126+
# Trigger release workflow
127+
echo "Triggering release workflow for $NEW_TAG"
128+
gh workflow run release.yml -f tag="$NEW_TAG"
117129
done

.github/workflows/release.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
name: Release Build and Publish
22

3+
# This workflow is triggered in two ways:
4+
# 1. Automatically when a semver tag is pushed (e.g., git push origin v1.0.0)
5+
# 2. Via workflow_dispatch from manage-release-tags.yml
6+
# (needed because tags created with GITHUB_TOKEN don't trigger on.push.tags events)
37
on:
48
push:
59
tags:
610
- 'v*.*.*'
11+
workflow_dispatch:
12+
inputs:
13+
tag:
14+
description: 'Tag to release (e.g., v1.0.0)'
15+
required: true
16+
type: string
717

818
env:
919
REGISTRY: ghcr.io
@@ -22,6 +32,8 @@ jobs:
2232
uses: actions/checkout@v4
2333
with:
2434
fetch-depth: 0
35+
# Use tag from workflow_dispatch input, otherwise use the git ref from tag push
36+
ref: ${{ inputs.tag || github.ref }}
2537

2638
- name: Free up disk space
2739
run: |
@@ -47,7 +59,13 @@ jobs:
4759
- name: Parse version from tag
4860
id: version
4961
run: |
50-
TAG=${GITHUB_REF#refs/tags/v}
62+
# Handle both trigger types: workflow_dispatch (from manage-release-tags) and tag push
63+
if [ -n "${{ inputs.tag }}" ]; then
64+
TAG="${{ inputs.tag }}"
65+
TAG=${TAG#v}
66+
else
67+
TAG=${GITHUB_REF#refs/tags/v}
68+
fi
5169
echo "full=$TAG" >> $GITHUB_OUTPUT
5270
5371
MAJOR=$(echo $TAG | cut -d. -f1)

0 commit comments

Comments
 (0)