-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (68 loc) · 2.38 KB
/
Copy pathrelease.yml
File metadata and controls
77 lines (68 loc) · 2.38 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
name: Release on merge
on:
pull_request:
types: [closed]
branches: [main]
permissions:
contents: write
jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
env:
MODULE_PATH: ${{ github.repository }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Go 1.24
uses: actions/setup-go@v6
with:
go-version: "1.24"
- name: Decide bump from PR labels (default=patch)
id: decide
run: |
echo '${{ toJson(github.event.pull_request.labels) }}' > /tmp/labels.json
BUMP=patch
grep -qi 'release:major' /tmp/labels.json && BUMP=major
grep -qi 'release:minor' /tmp/labels.json && BUMP=minor
grep -qi 'release:patch' /tmp/labels.json && BUMP=patch
echo "bump=$BUMP" >> $GITHUB_OUTPUT
echo "BUMP=$BUMP"
- name: Run tests (race + coverage)
run: |
make fmt
make vet
make test-race-cover
go tool cover -func=coverage.out | tail -n1 || true
- name: Compute next semver tag
id: bump
shell: bash
run: |
set -euo pipefail
LAST_TAG="$(git describe --tags --abbrev=0 2>/dev/null || echo 'v0.1.0')"
echo "LAST_TAG=$LAST_TAG"
VER="${LAST_TAG#v}"
IFS='.' read -r MA MI PA <<< "$VER"
case "${{ steps.decide.outputs.bump }}" in
major) MA=$((MA+1)); MI=0; PA=0;;
minor) MI=$((MI+1)); PA=0;;
patch) PA=$((PA+1));;
esac
NEXT_TAG="v${MA}.${MI}.${PA}"
echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
echo "NEXT_TAG=$NEXT_TAG"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.bump.outputs.next_tag }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prime Go proxy (make the tag discoverable)
run: |
MOD="github.com/${{ github.repository }}"
TAG="${{ steps.bump.outputs.next_tag }}"
GOPROXY=proxy.golang.org go list -m -versions "$MOD" || true
GOPROXY=proxy.golang.org go list -m "$MOD@$TAG" || true