Skip to content

Commit 3fcc6fa

Browse files
committed
Add release starter workflow
- Accepts a version input - Runs only on workflow_dispatch - Validates version.go (guardrail) - Push the tag so the the current build workflow kicks-in
1 parent 67601ca commit 3fcc6fa

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

.github/workflows/release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'Version to release (e.g., v1.4.1)'
7+
required: true
8+
type: string
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
create-release-tag:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
19+
with:
20+
fetch-depth: 0
21+
persist-credentials: true
22+
23+
- name: Validate version format
24+
run: |
25+
VERSION="${{ github.event.inputs.version }}"
26+
if [[ ! "${VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
27+
echo "ERROR: Version must follow semver format (e.g., v1.4.1 or v1.4.1-rc1)"
28+
exit 1
29+
fi
30+
echo "Version format is valid: ${VERSION}"
31+
32+
- name: Validate version.go matches input
33+
run: |
34+
CODE_VERSION=$(grep -oP 'const Version = "\K[^"]+' internal/build/version.go)
35+
INPUT_VERSION="${{ github.event.inputs.version }}"
36+
INPUT_VERSION="${INPUT_VERSION#v}"
37+
38+
echo "Version in version.go: ${CODE_VERSION}"
39+
echo "Version from input: ${INPUT_VERSION}"
40+
41+
if [[ "${CODE_VERSION}" != "${INPUT_VERSION}" ]]; then
42+
echo ""
43+
echo "ERROR: Version mismatch!"
44+
echo " version.go has: ${CODE_VERSION}"
45+
echo " Input version: ${INPUT_VERSION}"
46+
echo ""
47+
echo "Please update internal/build/version.go to match ${INPUT_VERSION}"
48+
exit 1
49+
fi
50+
51+
echo "✓ Version check passed: ${CODE_VERSION}"
52+
53+
- name: Check if tag already exists
54+
run: |
55+
VERSION="${{ github.event.inputs.version }}"
56+
if git rev-parse "${VERSION}" >/dev/null 2>&1; then
57+
echo "ERROR: Tag ${VERSION} already exists"
58+
exit 1
59+
fi
60+
echo "✓ Tag ${VERSION} does not exist yet"
61+
62+
- name: Create and push tag
63+
run: |
64+
VERSION="${{ github.event.inputs.version }}"
65+
git config user.name "github-actions[bot]"
66+
git config user.email "github-actions[bot]@users.noreply.github.com"
67+
68+
git tag -a "${VERSION}" -m "Release ${VERSION}"
69+
git push origin "${VERSION}"
70+
71+
echo "✓ Tag ${VERSION} created and pushed successfully"
72+
echo "The build workflow will now automatically start"
73+

0 commit comments

Comments
 (0)