-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (54 loc) · 1.68 KB
/
Copy pathrelease.yml
File metadata and controls
64 lines (54 loc) · 1.68 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
name: release
on:
push:
tags: ['v*']
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Refuse a tag that is not on main
run: |
git fetch --no-tags --quiet origin main
if ! git merge-base --is-ancestor "${GITHUB_SHA}" origin/main; then
echo "${GITHUB_REF_NAME} points at a commit that is not on main"
exit 1
fi
- run: go vet ./...
- run: go test ./...
- name: Build the release archives
run: make dist VERSION="${GITHUB_REF_NAME}"
- name: Take the release notes from the changelog
run: |
version="${GITHUB_REF_NAME#v}"
awk -v v="$version" '
index($0, "## [" v "]") == 1 { inside = 1; next }
inside && /^## / { exit }
inside { print }
' CHANGELOG.md | sed '/./,$!d' > notes.md
if [ -s notes.md ]; then
echo "notes=--notes-file notes.md" >> "$GITHUB_ENV"
else
echo "CHANGELOG.md has no section for $version, generating notes from commits"
echo "notes=--generate-notes" >> "$GITHUB_ENV"
fi
- name: Publish the release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${GITHUB_REF_NAME}" \
--title "${GITHUB_REF_NAME}" \
--verify-tag \
$notes \
dist/*.tar.gz dist/SHA256SUMS