-
Notifications
You must be signed in to change notification settings - Fork 229
294 lines (249 loc) · 8.3 KB
/
release.yml
File metadata and controls
294 lines (249 loc) · 8.3 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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: Release
on:
push:
tags:
- "*"
tags-ignore:
- "passkey-bundler/v*"
permissions:
contents: write
packages: write
jobs:
version:
name: Extract Version
runs-on: ubuntu-latest
outputs:
value: ${{ steps.extract.outputs.version }}
steps:
- name: Extract version from tag
id: extract
run: |
TAG_REF="${GITHUB_REF#refs/tags/}"
VERSION_WITHOUT_V="${TAG_REF#v}"
echo "version=$VERSION_WITHOUT_V" >> "$GITHUB_OUTPUT"
build-binaries:
name: Build Binaries
needs:
- version
strategy:
fail-fast: true
matrix:
build:
- platform: linux/amd64
runner: ubuntu-24.04
- platform: linux/arm64
runner: ubuntu-24.04-arm
- platform: darwin/arm64
runner: macos-latest
- platform: darwin/amd64
runner: macos-latest
runs-on: ${{ matrix.build.runner }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Prepare env vars
run: |
OS=$(echo "${{ matrix.build.platform }}" | cut -d '/' -f 1)
ARCH=$(echo "${{ matrix.build.platform }}" | cut -d '/' -f 2)
FINAL_NAME="nibid_${{ needs.version.outputs.value }}_${OS}_${ARCH}"
echo "OS=$OS" >> $GITHUB_ENV
echo "ARCH=$ARCH" >> $GITHUB_ENV
echo "FINAL_NAME=$FINAL_NAME" >> $GITHUB_ENV
- name: Build
run: |
GOARCH=${{ env.ARCH }} VERSION=${{ needs.version.outputs.value }} make build
tar czf ${{ env.FINAL_NAME }}.tar.gz -C build nibid
- name: Upload artifact
uses: actions/upload-artifact@v5
with:
name: ${{ env.FINAL_NAME }}
path: ${{ env.FINAL_NAME }}.tar.gz
build-darwin-universal:
name: Build Darwin Universal Binary
needs:
- version
- build-binaries
if: ${{ success() }}
runs-on: macos-latest
steps:
- name: Prepare env vars
run: |
DARWIN_NAME=nibid_${{ needs.version.outputs.value }}_darwin
echo "DARWIN_NAME_ARM64=${DARWIN_NAME}_arm64" >> $GITHUB_ENV
echo "DARWIN_NAME_AMD64=${DARWIN_NAME}_amd64" >> $GITHUB_ENV
echo "DARWIN_NAME_ALL=${DARWIN_NAME}_all" >> $GITHUB_ENV
- name: Download arm64 artifact
uses: actions/download-artifact@v6
with:
name: ${{ env.DARWIN_NAME_ARM64 }}
path: ./arm64
- name: Download amd64 artifact
uses: actions/download-artifact@v6
with:
name: ${{ env.DARWIN_NAME_AMD64 }}
path: ./amd64
- name: Extract artifacts
run: |
mkdir -p arm64_bin amd64_bin
tar xzf arm64/${DARWIN_NAME_ARM64}.tar.gz -C arm64_bin
tar xzf amd64/${DARWIN_NAME_AMD64}.tar.gz -C amd64_bin
- name: Create universal binary
run: |
mkdir -p ${{ env.DARWIN_NAME_ALL }}
lipo -create -output ${{ env.DARWIN_NAME_ALL }}/nibid amd64_bin/nibid arm64_bin/nibid
- name: Compress universal binary
run: tar czf ${{ env.DARWIN_NAME_ALL }}.tar.gz -C ${{ env.DARWIN_NAME_ALL }} nibid
- name: Upload artifact
uses: actions/upload-artifact@v5
with:
name: ${{ env.DARWIN_NAME_ALL }}
path: ${{ env.DARWIN_NAME_ALL }}.tar.gz
build-push-docker:
name: Build and Push Nibiru Image
needs:
- version
- build-binaries
if: ${{ success() }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Prepare env vars
run: |
LINUX_NAME=nibid_${{ needs.version.outputs.value }}_linux
echo "LINUX_NAME_ARM64=${LINUX_NAME}_arm64" >> $GITHUB_ENV
echo "LINUX_NAME_AMD64=${LINUX_NAME}_amd64" >> $GITHUB_ENV
- name: Download arm64 artifact
uses: actions/download-artifact@v6
with:
name: ${{ env.LINUX_NAME_ARM64 }}
- name: Download amd64 artifact
uses: actions/download-artifact@v6
with:
name: ${{ env.LINUX_NAME_AMD64 }}
- name: Extract artifacts
run: |
mkdir -p dist/arm64 dist/amd64
tar xzf ${{ env.LINUX_NAME_ARM64 }}.tar.gz -C dist/arm64
tar xzf ${{ env.LINUX_NAME_AMD64 }}.tar.gz -C dist/amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR container register
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: ${{ needs.version.outputs.value }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
target: release
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: src=external
build-push-chaosnet:
name: Build and Push Chaosnet Image
needs:
- version
- build-binaries
if: ${{ success() }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Prepare env vars
run: |
LINUX_NAME=nibid_${{ needs.version.outputs.value }}_linux
echo "LINUX_NAME_ARM64=${LINUX_NAME}_arm64" >> $GITHUB_ENV
echo "LINUX_NAME_AMD64=${LINUX_NAME}_amd64" >> $GITHUB_ENV
- name: Download arm64 artifact
uses: actions/download-artifact@v6
with:
name: ${{ env.LINUX_NAME_ARM64 }}
- name: Download amd64 artifact
uses: actions/download-artifact@v6
with:
name: ${{ env.LINUX_NAME_AMD64 }}
- name: Extract artifacts
run: |
mkdir -p dist/arm64 dist/amd64
tar xzf ${{ env.LINUX_NAME_ARM64 }}.tar.gz -C dist/arm64
tar xzf ${{ env.LINUX_NAME_AMD64 }}.tar.gz -C dist/amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR container register
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/chaosnet
tags: ${{ needs.version.outputs.value }}
- name: Build and push image
uses: docker/build-push-action@v6
with:
target: release
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: src=external
publish-release:
name: Publish Release
needs:
- version
- build-binaries
- build-darwin-universal
if: ${{ success() }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v6
with:
path: dist
pattern: nibid_${{ needs.version.outputs.value }}_*
merge-multiple: true
- name: Generate checksums
run: |
cd dist
ls -la
shasum -a 256 *.tar.gz > nibid_${{ needs.version.outputs.value }}_checksums.txt
- name: Generate changelog
id: changes
run: |
PREV_TAG=$(git tag --sort=-creatordate | grep -Ev 'rc|alpha|beta|p.*' | sed -n '2p')
echo "Previous tag: $PREV_TAG"
CHANGELOG=$(git log "$PREV_TAG"..HEAD --pretty=format:'- %h %s')
echo "$CHANGELOG"
echo "changes<<EOF" >> "$GITHUB_OUTPUT"
echo "$CHANGELOG" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Publish Release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changes.outputs.changes }}
files: |
dist/**/*.tar.gz
dist/nibid_${{ needs.version.outputs.value }}_checksums.txt