Skip to content

Commit 04bae45

Browse files
committed
fix(ci): collapse release workflows into one
- keep a single manual release workflow that computes the next tag and publishes with GoReleaser - remove the redundant cut-release workflow and rename the remaining workflow to Release - quote the validate run-name expression so YAML no longer treats the PR # marker as a comment
1 parent 0ad0a7a commit 04bae45

3 files changed

Lines changed: 80 additions & 116 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Validate
2-
run-name: Validate ${{ github.event_name == 'pull_request' && format('PR #{0}', github.event.pull_request.number) || github.ref_name }}
2+
run-name: "${{ github.event_name == 'pull_request' && format('Validate PR #{0}', github.event.pull_request.number) || format('Validate {0}', github.ref_name) }}"
33

44
on:
55
pull_request:

.github/workflows/cut-release.yml

Lines changed: 0 additions & 109 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,98 @@
1-
name: Publish Tagged Release
2-
run-name: Publish ${{ github.ref_name }}
1+
name: Release
2+
run-name: "${{ format('Release {0} from {1}', inputs.bump, github.ref_name) }}"
33

44
on:
5-
push:
6-
tags:
7-
- "v*"
5+
workflow_dispatch:
6+
inputs:
7+
bump:
8+
description: Semantic version increment for the next release tag
9+
required: true
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
815

916
permissions:
1017
contents: write
1118

19+
concurrency:
20+
group: release
21+
cancel-in-progress: false
22+
1223
jobs:
1324
release:
14-
name: Publish release assets
25+
name: Tag and publish release
1526
runs-on: ubuntu-latest
1627

1728
steps:
29+
- name: Ensure the workflow runs from main
30+
run: |
31+
if [ "${GITHUB_REF_NAME}" != "main" ]; then
32+
echo "This workflow must be run from main, got ${GITHUB_REF_NAME}." >&2
33+
exit 1
34+
fi
35+
1836
- name: Checkout
1937
uses: actions/checkout@v6.0.2
2038
with:
2139
fetch-depth: 0
2240

41+
- name: Determine next release tag
42+
id: next
43+
env:
44+
BUMP: ${{ inputs.bump }}
45+
run: |
46+
set -euo pipefail
47+
48+
latest_tag="$(git tag --list 'v*' --sort=-v:refname | awk '/^v[0-9]+\.[0-9]+\.[0-9]+$/ { print; exit }')"
49+
50+
if [ -z "${latest_tag}" ]; then
51+
next_tag="v0.1.0"
52+
else
53+
version="${latest_tag#v}"
54+
IFS='.' read -r major minor patch <<<"${version}"
55+
56+
case "${BUMP}" in
57+
patch)
58+
patch=$((patch + 1))
59+
;;
60+
minor)
61+
minor=$((minor + 1))
62+
patch=0
63+
;;
64+
major)
65+
major=$((major + 1))
66+
minor=0
67+
patch=0
68+
;;
69+
*)
70+
echo "Unsupported bump: ${BUMP}" >&2
71+
exit 1
72+
;;
73+
esac
74+
75+
next_tag="v${major}.${minor}.${patch}"
76+
fi
77+
78+
echo "tag=${next_tag}" >> "${GITHUB_OUTPUT}"
79+
80+
- name: Create annotated tag
81+
env:
82+
TAG: ${{ steps.next.outputs.tag }}
83+
run: |
84+
set -euo pipefail
85+
86+
if git rev-parse "${TAG}" >/dev/null 2>&1; then
87+
echo "Tag ${TAG} already exists." >&2
88+
exit 1
89+
fi
90+
91+
git config user.name "github-actions[bot]"
92+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
93+
git tag -a "${TAG}" -m "Release ${TAG}"
94+
git push origin "${TAG}"
95+
2396
- name: Set up Go
2497
uses: actions/setup-go@v6.4.0
2598
with:

0 commit comments

Comments
 (0)