-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (144 loc) · 5.76 KB
/
release.yml
File metadata and controls
166 lines (144 loc) · 5.76 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Release version (e.g. v1.0.0)"
required: true
type: string
permissions:
contents: write
id-token: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Validate version format
run: |
VERSION="${{ github.event.inputs.version }}"
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must match vX.Y.Z (e.g. v1.0.0)"
exit 1
fi
- name: Checkout code
uses: actions/checkout@v6
with:
token: ${{ secrets.RELEASE_TOKEN }}
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.25.9"
cache: true
- name: Install git-cliff
run: pip install git-cliff
- name: Install goreleaser
uses: goreleaser/goreleaser-action@v6
with:
install-only: true
- name: Generate changelog
run: |
# Full changelog for CHANGELOG.md (committed to repo)
make changelog VERSION=${{ github.event.inputs.version }}
# Release notes for this version only (passed to goreleaser)
git-cliff --tag ${{ github.event.inputs.version }} --latest --strip header -o RELEASE_NOTES.md
- name: Tag and push release
run: |
VERSION="${{ github.event.inputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.RELEASE_TOKEN }}@github.com/${{ github.repository }}
git tag "${VERSION}"
git push origin --tags
- name: Install cosign
uses: sigstore/cosign-installer@v3
- name: Build and release with goreleaser
uses: goreleaser/goreleaser-action@v6
with:
args: release --clean --release-notes RELEASE_NOTES.md
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
- name: Generate binary checksums
run: |
VERSION="${{ github.event.inputs.version }}"
# Strip leading 'v' for goreleaser dist paths
VER="${VERSION#v}"
SUMFILE="dist/verda_${VER}_binary_SHA256SUMS"
# Find raw binaries produced by goreleaser and checksum them
for dir in dist/verda_*/; do
# Skip archive directories (contain .tar.gz or .zip artifacts)
[ -d "$dir" ] || continue
BIN=""
if [ -f "${dir}verda" ]; then
BIN="${dir}verda"
elif [ -f "${dir}verda.exe" ]; then
BIN="${dir}verda.exe"
else
continue
fi
# Compute checksum with path relative to dist/
RELPATH="${BIN#dist/}"
HASH=$(sha256sum "$BIN" | awk '{print $1}')
echo "${HASH} ${RELPATH}" >> "$SUMFILE"
done
# Dedup in case build and archive staging dirs both matched
sort -u -o "$SUMFILE" "$SUMFILE"
if [ ! -s "$SUMFILE" ]; then
echo "Error: no binary checksums generated"
exit 1
fi
echo "--- Binary checksums ---"
cat "$SUMFILE"
- name: Sign checksum files with cosign
# Keyless signing via GitHub OIDC. The certificate identity will be:
# https://github.com/verda-cloud/verda-cli/.github/workflows/release.yml@refs/heads/main
#
# To verify manually:
# cosign verify-blob \
# --signature verda_<VER>_SHA256SUMS.sig \
# --certificate verda_<VER>_SHA256SUMS.pem \
# --certificate-identity-regexp "^https://github\.com/verda-cloud/verda-cli/\.github/workflows/release\.yml@refs/.*$" \
# --certificate-oidc-issuer https://token.actions.githubusercontent.com \
# verda_<VER>_SHA256SUMS
run: |
VERSION="${{ github.event.inputs.version }}"
VER="${VERSION#v}"
# Sign the archive checksums (produced by goreleaser)
cosign sign-blob --yes \
--output-signature "dist/verda_${VER}_SHA256SUMS.sig" \
--output-certificate "dist/verda_${VER}_SHA256SUMS.pem" \
"dist/verda_${VER}_SHA256SUMS"
# Sign the binary checksums
cosign sign-blob --yes \
--output-signature "dist/verda_${VER}_binary_SHA256SUMS.sig" \
--output-certificate "dist/verda_${VER}_binary_SHA256SUMS.pem" \
"dist/verda_${VER}_binary_SHA256SUMS"
- name: Upload signing artifacts to release
env:
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
VERSION="${{ github.event.inputs.version }}"
VER="${VERSION#v}"
gh release upload "${VERSION}" \
"dist/verda_${VER}_binary_SHA256SUMS" \
"dist/verda_${VER}_binary_SHA256SUMS.sig" \
"dist/verda_${VER}_binary_SHA256SUMS.pem" \
"dist/verda_${VER}_SHA256SUMS.sig" \
"dist/verda_${VER}_SHA256SUMS.pem"
- name: Commit changelog and create PR
env:
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
VERSION="${{ github.event.inputs.version }}"
BRANCH="chore/changelog-${VERSION}"
git checkout -b "${BRANCH}"
git add CHANGELOG.md
git commit -m "chore(release): update changelog for ${VERSION}"
git push origin "${BRANCH}"
gh pr create \
--base main \
--head "${BRANCH}" \
--title "chore(release): update changelog for ${VERSION}" \
--body "Updates CHANGELOG.md with release notes for ${VERSION}."