Skip to content

Commit 9d332c1

Browse files
authored
Merge pull request #75 from stephenleo/71-story-8-1-manual-release-trigger
feat(#71): add manual release trigger with version input and tag creation
2 parents 0ba7d0a + a85a7a0 commit 9d332c1

1 file changed

Lines changed: 46 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,54 @@ on:
55
tags:
66
- 'v*'
77
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version tag to create and release (e.g. v1.2.3)'
11+
required: true
12+
type: string
13+
14+
concurrency:
15+
group: release
16+
cancel-in-progress: false
817

918
jobs:
19+
tag:
20+
name: Create and Push Tag
21+
if: github.event_name == 'workflow_dispatch'
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Validate version format
28+
env:
29+
VERSION: ${{ github.event.inputs.version }}
30+
run: |
31+
if ! echo "$VERSION" | grep -qE '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
32+
echo "ERROR: Version must match vX.Y.Z format (e.g. v1.2.3)"
33+
exit 1
34+
fi
35+
- name: Verify tag does not already exist
36+
env:
37+
VERSION: ${{ github.event.inputs.version }}
38+
run: |
39+
if git ls-remote --tags origin "refs/tags/$VERSION" | grep -qF "$VERSION"; then
40+
echo "ERROR: Tag $VERSION already exists on remote. Aborting."
41+
exit 1
42+
fi
43+
- name: Create and push tag
44+
env:
45+
VERSION: ${{ github.event.inputs.version }}
46+
run: |
47+
git config user.name "github-actions[bot]"
48+
git config user.email "github-actions[bot]@users.noreply.github.com"
49+
git tag "$VERSION"
50+
git push origin "$VERSION"
51+
1052
test:
1153
name: Test (${{ matrix.os }})
54+
needs: [tag]
55+
if: "!cancelled() && (needs.tag.result == 'success' || needs.tag.result == 'skipped')"
1256
runs-on: ${{ matrix.os }}
1357
strategy:
1458
matrix:
@@ -67,13 +111,14 @@ jobs:
67111

68112
release:
69113
name: Publish GitHub Release
70-
if: startsWith(github.ref, 'refs/tags/')
71114
needs: build
115+
if: "!cancelled() && needs.build.result == 'success'"
72116
runs-on: ubuntu-latest
73117
permissions:
74118
contents: write
75119
steps:
76120
- uses: actions/download-artifact@v4
77121
- uses: softprops/action-gh-release@v2
78122
with:
123+
tag_name: ${{ github.event.inputs.version || github.ref_name }}
79124
files: cship-*/cship-*

0 commit comments

Comments
 (0)