-
Notifications
You must be signed in to change notification settings - Fork 5
85 lines (77 loc) · 2.44 KB
/
Copy pathrelease.yaml
File metadata and controls
85 lines (77 loc) · 2.44 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.5.0). Leave empty to auto-bump patch version.'
required: false
type: string
bump:
description: 'Version bump type (only used if version is empty)'
required: false
type: choice
default: 'patch'
options:
- patch
- minor
- major
permissions:
contents: write
jobs:
create-tag:
runs-on: ubuntu-24.04
outputs:
tag: ${{ steps.compute-tag.outputs.tag }}
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
fetch-depth: 0
- id: compute-tag
run: |
if [ -n "${{ inputs.version }}" ]; then
TAG="v${{ inputs.version }}"
else
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
VERSION=${LATEST_TAG#v}
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
case "${{ inputs.bump }}" in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac
TAG="v${MAJOR}.${MINOR}.${PATCH}"
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Computed tag: $TAG"
- name: Create and push tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a ${{ steps.compute-tag.outputs.tag }} -m "Release ${{ steps.compute-tag.outputs.tag }}"
git push origin ${{ steps.compute-tag.outputs.tag }}
goreleaser:
needs: create-tag
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
with:
fetch-depth: 0
ref: ${{ needs.create-tag.outputs.tag }}
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: go.mod
- uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
with:
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}