File tree Expand file tree Collapse file tree 2 files changed +138
-0
lines changed
Expand file tree Collapse file tree 2 files changed +138
-0
lines changed Original file line number Diff line number Diff line change 1+ name : release
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ version :
7+ description : ' Version to release (e.g., 1.5.0). Leave empty to auto-bump patch version.'
8+ required : false
9+ type : string
10+ bump :
11+ description : ' Version bump type (only used if version is empty)'
12+ required : false
13+ type : choice
14+ default : ' patch'
15+ options :
16+ - patch
17+ - minor
18+ - major
19+
20+ permissions :
21+ contents : write
22+
23+ jobs :
24+ create-tag :
25+ runs-on : ubuntu-24.04
26+ outputs :
27+ tag : ${{ steps.compute-tag.outputs.tag }}
28+ steps :
29+ - uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
30+ with :
31+ fetch-depth : 0
32+ - id : compute-tag
33+ run : |
34+ if [ -n "${{ inputs.version }}" ]; then
35+ TAG="v${{ inputs.version }}"
36+ else
37+ LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
38+ VERSION=${LATEST_TAG#v}
39+
40+ IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
41+
42+ case "${{ inputs.bump }}" in
43+ major)
44+ MAJOR=$((MAJOR + 1))
45+ MINOR=0
46+ PATCH=0
47+ ;;
48+ minor)
49+ MINOR=$((MINOR + 1))
50+ PATCH=0
51+ ;;
52+ patch)
53+ PATCH=$((PATCH + 1))
54+ ;;
55+ esac
56+
57+ TAG="v${MAJOR}.${MINOR}.${PATCH}"
58+ fi
59+
60+ echo "tag=$TAG" >> $GITHUB_OUTPUT
61+ echo "Computed tag: $TAG"
62+ - name : Create and push tag
63+ run : |
64+ git config user.name "github-actions[bot]"
65+ git config user.email "github-actions[bot]@users.noreply.github.com"
66+ git tag -a ${{ steps.compute-tag.outputs.tag }} -m "Release ${{ steps.compute-tag.outputs.tag }}"
67+ git push origin ${{ steps.compute-tag.outputs.tag }}
68+
69+ goreleaser :
70+ needs : create-tag
71+ runs-on : ubuntu-24.04
72+ steps :
73+ - uses : actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
74+ with :
75+ fetch-depth : 0
76+ ref : ${{ needs.create-tag.outputs.tag }}
77+ - uses : actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
78+ with :
79+ go-version-file : go.mod
80+ - uses : goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
81+ with :
82+ version : " ~> v2"
83+ args : release --clean
84+ env :
85+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change 1+ version : 2
2+
3+ before :
4+ hooks :
5+ - go mod tidy
6+
7+ builds :
8+ - env :
9+ - CGO_ENABLED=0
10+ main : ./cmd/release-tool
11+ id : release-tool
12+ binary : release-tool
13+ mod_timestamp : ' {{ .CommitTimestamp }}'
14+ flags :
15+ - -trimpath
16+ ldflags :
17+ - ' -s -w'
18+ goos :
19+ - linux
20+ - darwin
21+ - windows
22+ goarch :
23+ - amd64
24+ - arm64
25+
26+ archives :
27+ - format : tar.gz
28+ name_template : >-
29+ {{ .ProjectName }}_
30+ {{- title .Os }}_
31+ {{- if eq .Arch "amd64" }}x86_64
32+ {{- else if eq .Arch "386" }}i386
33+ {{- else }}{{ .Arch }}{{ end }}
34+ {{- if .Arm }}v{{ .Arm }}{{ end }}
35+ format_overrides :
36+ - goos : windows
37+ format : zip
38+ files :
39+ - LICENSE
40+ - README.md
41+
42+ changelog :
43+ sort : asc
44+ filters :
45+ exclude :
46+ - ' ^docs:'
47+ - ' ^test:'
48+ - ' ^ci:'
49+ - ' ^chore:'
50+
51+ release :
52+ draft : false
53+ prerelease : auto
You can’t perform that action at this time.
0 commit comments