-
Notifications
You must be signed in to change notification settings - Fork 0
251 lines (219 loc) · 7.33 KB
/
Copy pathrelease.yaml
File metadata and controls
251 lines (219 loc) · 7.33 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: release
on:
push:
tags:
- 'v*'
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# Run required checks before creating release
pre-commit:
uses: ./.github/workflows/pre-commit.yaml
tests:
uses: ./.github/workflows/test.yaml
create-release:
needs: [pre-commit, tests]
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
- name: Get version
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
VERSION=$(git describe --tags --always)
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Version: ${VERSION}"
- name: Extract release notes from CHANGELOG
id: extract_notes
run: |
VERSION=${{ steps.get_version.outputs.version }}
# Extract notes for this version from CHANGELOG.md
if [ -f CHANGELOG.md ]; then
# Get content between version header and next version or end
NOTES=$(awk "/## \[${VERSION#v}\]/{flag=1; next} /## \[/{flag=0} flag" CHANGELOG.md)
if [ -z "$NOTES" ]; then
NOTES="Release ${VERSION}"$'\n\n'"Built with Neutrino v0.18.0"$'\n\n'"See [CHANGELOG.md](CHANGELOG.md) for details."
fi
else
NOTES="Release ${VERSION}"
fi
echo "notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{ steps.get_version.outputs.version }} \
--title "${{ steps.get_version.outputs.version }}" \
--notes-file - <<'EOF'
${{ steps.extract_notes.outputs.notes }}
EOF
build-binaries:
needs: create-release
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
include:
- goos: linux
goarch: amd64
output: neutrinod-linux-amd64
- goos: linux
goarch: 386
output: neutrinod-linux-386
- goos: linux
goarch: arm64
output: neutrinod-linux-arm64
- goos: linux
goarch: arm
goarm: 7
output: neutrinod-linux-armv7
- goos: linux
goarch: arm
goarm: 6
output: neutrinod-linux-armv6
- goos: darwin
goarch: amd64
output: neutrinod-darwin-amd64
- goos: darwin
goarch: arm64
output: neutrinod-darwin-arm64
- goos: windows
goarch: amd64
output: neutrinod-windows-amd64.exe
- goos: windows
goarch: arm64
output: neutrinod-windows-arm64.exe
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
- name: Get reproducible build timestamp
id: source_date
run: echo "epoch=$(git log -1 --pretty=%ct)" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v7.0.0
with:
go-version: '1.27.0'
cache-dependency-path: neutrino_server/go.sum
- name: Get dependencies
working-directory: neutrino_server
run: go mod download
- name: Build binary
working-directory: neutrino_server
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
CGO_ENABLED: 0
SOURCE_DATE_EPOCH: ${{ steps.source_date.outputs.epoch }}
run: |
VERSION=${{ needs.create-release.outputs.version }}
go build \
-trimpath \
-buildvcs=false \
-ldflags="-buildid= -s -w -X main.version=${VERSION}" \
-o ${{ matrix.output }} \
./cmd/neutrinod
- name: Upload binary artifact
uses: actions/upload-artifact@v7.0.1
with:
name: binary-${{ matrix.output }}
path: neutrino_server/${{ matrix.output }}
if-no-files-found: error
build-docker:
needs: create-release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
- name: Set up QEMU
uses: docker/setup-qemu-action@v4.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.3.0
- name: Log in to Container registry
uses: docker/login-action@v4.6.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6.2.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v7.3.0
with:
context: ./neutrino_server
file: ./neutrino_server/Dockerfile
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
VERSION=${{ needs.create-release.outputs.version }}
BUILD_TIME=${{ github.event.repository.updated_at }}
COMMIT=${{ github.sha }}
checksums:
needs: [create-release, build-binaries]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
- name: Download built binaries
uses: actions/download-artifact@v8.0.1
with:
pattern: binary-*
path: artifacts
merge-multiple: true
- name: Generate checksums
run: |
cd artifacts
sha256sum neutrinod-* | sort > SHA256SUMS
cat SHA256SUMS
- name: Verify signed checksums from repository
run: |
VERSION=${{ needs.create-release.outputs.version }}
EXPECTED_DIR="signatures/${VERSION}"
test -f "${EXPECTED_DIR}/SHA256SUMS"
test -f "${EXPECTED_DIR}/SHA256SUMS.asc"
diff -u "${EXPECTED_DIR}/SHA256SUMS" "artifacts/SHA256SUMS"
for pubkey in signatures/pubkeys/*.asc; do
gpg --import "$pubkey"
done
gpg --verify "${EXPECTED_DIR}/SHA256SUMS.asc" "artifacts/SHA256SUMS"
- name: Upload binaries, checksums, and signature
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION=${{ needs.create-release.outputs.version }}
gh release upload ${{ needs.create-release.outputs.version }} \
./artifacts/neutrinod-* \
./artifacts/SHA256SUMS \
"./signatures/${VERSION}/SHA256SUMS.asc" \
--repo ${{ github.repository }}