-
Notifications
You must be signed in to change notification settings - Fork 2
55 lines (49 loc) · 1.95 KB
/
tag-and-release.yml
File metadata and controls
55 lines (49 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Tag & Release Go Submodule
run-name: Release ${{github.event.inputs.module}} ${{github.event.inputs.version}}
on:
workflow_dispatch:
inputs:
module:
description: 'Module subdirectory (e.g., hooks/mesh_defaults)'
required: true
version:
description: 'Version to release (e.g., v1.2.0)'
required: true
jobs:
tag-release:
name: Tag & Release
runs-on: ubuntu-24.04
steps:
- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Validate inputs
run: |
MODULE="${{ github.event.inputs.module }}"
VERSION="${{ github.event.inputs.version }}"
# Check if module path exists and has go.mod
if [ ! -f "$MODULE/go.mod" ]; then
echo "❌ Module '$MODULE' does not exist or is missing go.mod"
exit 1
fi
# Validate version format (e.g., v1.2.3)
if ! [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "❌ Version '$VERSION' is not a valid semver (expected format: vMAJOR.MINOR.PATCH)"
exit 1
fi
TAG="${MODULE}/${VERSION}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "❌ Tag '$TAG' already exists. Aborting."
exit 1
fi
echo "✅ Inputs validated: module='$MODULE', version='$VERSION'"
- name: Create tag and GitHub release
uses: ncipollo/release-action@b12185d71f4641bb1b1116dacae6b74e667f86e4 # v1.19.0
with:
tag: ${{ github.event.inputs.module }}/${{ github.event.inputs.version }}
name: Release ${{ github.event.inputs.module }} ${{ github.event.inputs.version }}
body: |
Automated release for module **${{ github.event.inputs.module }}**
Version: **${{ github.event.inputs.version }}**
commit: ${{ github.sha }}
draft: false
prerelease: false