-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (49 loc) · 1.53 KB
/
release.yml
File metadata and controls
56 lines (49 loc) · 1.53 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
name: Release
on:
workflow_dispatch:
inputs:
bump:
description: "Version bump (patch | minor | major)"
type: choice
options:
- patch
- minor
- major
required: true
default: patch
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # allow push + release
steps:
- uses: actions/checkout@v4 # first-party
with:
fetch-depth: 0 # we need all tags
- uses: actions/setup-go@v5 # first-party
with:
go-version: '1.22'
# ───────── 1. figure out next tag ─────────
- id: version
shell: bash
run: |
last=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "previous=$last" >>"$GITHUB_OUTPUT"
v=${last#v}; IFS=. read -r major minor patch <<<"$v"
case "${{ github.event.inputs.bump }}" in
patch) patch=$((patch+1));;
minor) minor=$((minor+1)); patch=0;;
major) major=$((major+1)); minor=0; patch=0;;
esac
next="v${major}.${minor}.${patch}"
echo "next=$next" >>"$GITHUB_OUTPUT"
# ───────── 2. create & upload release ─────────
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
tag=${{ steps.version.outputs.next }}
gh release create "$tag" \
--title "$tag" \
--generate-notes