-
Notifications
You must be signed in to change notification settings - Fork 107
357 lines (343 loc) · 15.1 KB
/
release.yaml
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
name: Release
on:
push:
tags:
- "*.*.*"
# Running from workflow dispatch (AKA manual) will not publish anything.
# This is intended for testing changes to this flow.
workflow_dispatch:
jobs:
build_binaries_aarch64-unknown-linux-gnu:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: ""
- uses: taiki-e/install-action@v2
with:
tool: cross
# building layer and cli together leads to weird situation where embedded layer is x64, so split.
- name: build mirrord-layer
run: RUSTFLAGS="$RUSTFLAGS -A dead_code" cross build --release -p mirrord-layer --target=aarch64-unknown-linux-gnu
- name: build mirrord cli
env:
MIRRORD_LAYER_FILE: ../../../target/aarch64-unknown-linux-gnu/release/libmirrord_layer.so
run: RUSTFLAGS="$RUSTFLAGS -A dead_code" cross build --release -p mirrord --target=aarch64-unknown-linux-gnu
- uses: actions/upload-artifact@v4
with:
name: aarch64-unknown-linux-gnu
path: |
target/aarch64-unknown-linux-gnu/release/mirrord
target/aarch64-unknown-linux-gnu/release/libmirrord_layer.so
if-no-files-found: error
build_binaries_x86_64-unknown-linux-gnu:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: ""
- uses: taiki-e/install-action@v2
with:
tool: cross
- name: build mirrord-layer and cli
run: cross build --release -p mirrord -p mirrord-layer --target=x86_64-unknown-linux-gnu
- uses: actions/upload-artifact@v4
with:
name: x86_64-unknown-linux-gnu
path: |
target/x86_64-unknown-linux-gnu/release/mirrord
target/x86_64-unknown-linux-gnu/release/libmirrord_layer.so
if-no-files-found: error
build_binaries_macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- run: rm rust-toolchain.toml
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: x86_64-apple-darwin,aarch64-apple-darwin
toolchain: nightly-2024-10-11
rustflags: ""
- name: Import Code-Signing Certificates
uses: Apple-Actions/import-codesign-certs@v3
with:
# The certificates in a PKCS12 file encoded as a base64 string
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
# The password used to import the PKCS12 file.
p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}
- name: Install gon via HomeBrew for code signing and app notarization
run: |
brew tap mitchellh/gon
brew install mitchellh/gon/gon
# Instead of spoofing an arm64e by changing bits, we now use a code shim compiled as arm64e that loads the arm64 layer
- name: build mirrord-layer x86-64, arm and code shim
run: |
cargo +nightly-2024-10-11 build --release -p mirrord-layer --target=aarch64-apple-darwin
cargo +nightly-2024-10-11 build --release -p mirrord-layer --target=x86_64-apple-darwin
clang -arch arm64e -dynamiclib -o target/aarch64-apple-darwin/release/shim.dylib mirrord/layer/shim.c
- name: Sign layer binaries and code shim
env:
AC_USERNAME: ${{ secrets.APPLE_DEVELOPER }}
AC_PASSWORD: ${{ secrets.APPLE_DEVELOPER_PASSWORD }}
run: gon -log-level=debug -log-json .github/workflows/arch_dylib_sign.json
- name: create universal target dir
run: mkdir -p /tmp/target/universal-apple-darwin/release
- name: create universal dylib
run: lipo -create -output /tmp/target/universal-apple-darwin/release/libmirrord_layer.dylib target/aarch64-apple-darwin/release/shim.dylib target/aarch64-apple-darwin/release/libmirrord_layer.dylib target/x86_64-apple-darwin/release/libmirrord_layer.dylib
- name: Sign layer universal
env:
AC_USERNAME: ${{ secrets.APPLE_DEVELOPER }}
AC_PASSWORD: ${{ secrets.APPLE_DEVELOPER_PASSWORD }}
run: gon -log-level=debug -log-json .github/workflows/universal_dylib_sign.json
- name: build macOS arm cli with universal dylib
env:
MIRRORD_LAYER_FILE: /tmp/target/universal-apple-darwin/release/libmirrord_layer.dylib
MIRRORD_LAYER_FILE_MACOS_ARM64: ../../../target/aarch64-apple-darwin/release/libmirrord_layer.dylib
run: cargo +nightly-2024-10-11 build --release -p mirrord --target=aarch64-apple-darwin
- name: build macOS x86-64 cli with universal dylib
env:
MIRRORD_LAYER_FILE: /tmp/target/universal-apple-darwin/release/libmirrord_layer.dylib
run: cargo +nightly-2024-10-11 build --release -p mirrord --target=x86_64-apple-darwin
- name: Sign cli binaries
env:
AC_USERNAME: ${{ secrets.APPLE_DEVELOPER }}
AC_PASSWORD: ${{ secrets.APPLE_DEVELOPER_PASSWORD }}
run: gon -log-level=debug -log-json .github/workflows/arch_cli_sign.json
- name: create universal macOS cli
run: lipo -create -output /tmp/target/universal-apple-darwin/release/mirrord target/aarch64-apple-darwin/release/mirrord target/x86_64-apple-darwin/release/mirrord
- name: Sign universal cli
env:
AC_USERNAME: ${{ secrets.APPLE_DEVELOPER }}
AC_PASSWORD: ${{ secrets.APPLE_DEVELOPER_PASSWORD }}
run: gon -log-level=debug -log-json .github/workflows/universal_cli_sign.json
- name: adjust directory layout for upload
run: cp -rf /tmp/target .
- uses: actions/upload-artifact@v4
with:
name: universal-apple-darwin
path: |
target/universal-apple-darwin/release/mirrord
target/universal-apple-darwin/release/libmirrord_layer.dylib
if-no-files-found: error
release_docker_image:
runs-on: ubuntu-24.04
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get release version
run: |
echo "version=$(grep -m 1 version Cargo.toml | cut -d' ' -f3 | tr -d '\"')" >> $GITHUB_OUTPUT
id: version
- name: Build and push (test)
if: github.event_name == 'workflow_dispatch'
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: mirrord/agent/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/metalbear-co/mirrord-staging:${{ github.sha }}
- name: Build and push (final/release)
if: github.event_name != 'workflow_dispatch'
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: mirrord/agent/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/metalbear-co/mirrord:latest
ghcr.io/metalbear-co/mirrord:${{ steps.version.outputs.version }}
release_cli_docker_image:
runs-on: ubuntu-24.04
permissions:
packages: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get release version
run: |
echo "version=$(grep -m 1 version Cargo.toml | cut -d' ' -f3 | tr -d '\"')" >> $GITHUB_OUTPUT
id: version
- name: Build and push (test)
if: github.event_name == 'workflow_dispatch'
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: mirrord/cli/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/metalbear-co/mirrord-cli-staging:${{ github.sha }}
- name: Build and push (final/release)
if: github.event_name != 'workflow_dispatch'
uses: docker/build-push-action@v6
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
file: mirrord/cli/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/metalbear-co/mirrord-cli:${{ steps.version.outputs.version }}
release_gh:
needs:
[
build_binaries_aarch64-unknown-linux-gnu,
build_binaries_x86_64-unknown-linux-gnu,
build_binaries_macos,
release_docker_image,
release_cli_docker_image,
]
runs-on: ubuntu-24.04
if: github.event_name != 'workflow_dispatch'
permissions:
packages: write
contents: write
deployments: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: /tmp/artifacts
pattern: +(*-unknown-linux-gnu|*-apple-darwin)
- uses: montudor/action-zip@v1
- name: Create mirrord linux-x64 zip file
run: |
zip mirrord_linux_x86_64.zip mirrord
shasum -a 256 mirrord_linux_x86_64.zip > mirrord_linux_x86_64.shasum256
working-directory: /tmp/artifacts/x86_64-unknown-linux-gnu
- name: Create mirrord linux-aarch64 zip file
run: |
zip mirrord_linux_aarch64.zip mirrord
shasum -a 256 mirrord_linux_aarch64.zip > mirrord_linux_aarch64.shasum256
working-directory: /tmp/artifacts/aarch64-unknown-linux-gnu
- name: Create mirrord macos zip file
run: |
zip mirrord_mac_universal.zip mirrord
shasum -a 256 mirrord_mac_universal.zip > mirrord_mac_universal.shasum256
working-directory: /tmp/artifacts/universal-apple-darwin
# used for the homebrew formula
- uses: actions/upload-artifact@v4
with:
name: shasum
path: |
/tmp/artifacts/x86_64-unknown-linux-gnu/mirrord_linux_x86_64.shasum256
/tmp/artifacts/aarch64-unknown-linux-gnu/mirrord_linux_aarch64.shasum256
/tmp/artifacts/universal-apple-darwin/mirrord_mac_universal.shasum256
if-no-files-found: error
- name: Prepare binaries for upload
run: |
mkdir /tmp/release
mv /tmp/artifacts/x86_64-unknown-linux-gnu/libmirrord_layer.so /tmp/release/libmirrord_layer_linux_x86_64.so
mv /tmp/artifacts/x86_64-unknown-linux-gnu/mirrord /tmp/release/mirrord_linux_x86_64
mv /tmp/artifacts/x86_64-unknown-linux-gnu/mirrord_linux_x86_64.zip /tmp/release/mirrord_linux_x86_64.zip
mv /tmp/artifacts/x86_64-unknown-linux-gnu/mirrord_linux_x86_64.shasum256 /tmp/release/mirrord_linux_x86_64.shasum256
mv /tmp/artifacts/aarch64-unknown-linux-gnu/libmirrord_layer.so /tmp/release/libmirrord_layer_linux_aarch64.so
mv /tmp/artifacts/aarch64-unknown-linux-gnu/mirrord /tmp/release/mirrord_linux_aarch64
mv /tmp/artifacts/aarch64-unknown-linux-gnu/mirrord_linux_aarch64.zip /tmp/release/mirrord_linux_aarch64.zip
mv /tmp/artifacts/aarch64-unknown-linux-gnu/mirrord_linux_aarch64.shasum256 /tmp/release/mirrord_linux_aarch64.shasum256
mv /tmp/artifacts/universal-apple-darwin/libmirrord_layer.dylib /tmp/release/libmirrord_layer_mac_universal.dylib
mv /tmp/artifacts/universal-apple-darwin/mirrord /tmp/release/mirrord_mac_universal
mv /tmp/artifacts/universal-apple-darwin/mirrord_mac_universal.zip /tmp/release/mirrord_mac_universal.zip
mv /tmp/artifacts/universal-apple-darwin/mirrord_mac_universal.shasum256 /tmp/release/mirrord_mac_universal.shasum256
# Consider to add changelog generation..
- name: Release
uses: softprops/action-gh-release@v1
with:
files: /tmp/release/**
release_homebrew:
needs: release_gh
runs-on: ubuntu-24.04
if: github.event_name != 'workflow_dispatch'
steps:
- uses: actions/download-artifact@v4
with:
name: shasum
path: /tmp/artifacts
- uses: actions/checkout@v4
- name: Get release version and hashes
shell: bash # for -o pipefail, see https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
run: |
echo "version=$(grep -m 1 version Cargo.toml | cut -d' ' -f3 | tr -d '\"' | cut -d'-' -f1)" >> $GITHUB_ENV
echo "sha256_mac=$(cat /tmp/artifacts/universal-apple-darwin/mirrord_mac_universal.shasum256 | awk '{ print $1 }')" >> $GITHUB_ENV
echo "sha256_linux_aarch64=$(cat /tmp/artifacts/aarch64-unknown-linux-gnu/mirrord_linux_aarch64.shasum256 | awk '{ print $1 }')" >> $GITHUB_ENV
echo "sha256_linux_x86_64=$(cat /tmp/artifacts/x86_64-unknown-linux-gnu/mirrord_linux_x86_64.shasum256 | awk '{ print $1 }')" >> $GITHUB_ENV
- name: Checkout into homebrew-mirrord
uses: actions/checkout@v4
with:
repository: metalbear-co/homebrew-mirrord
path: ./
token: ${{ secrets.BREW_GITHUB_PAT }}
- name: Update hashes and urls
run: |
sed -i -e 's/\([0-9]\+\.[0-9]\+\.[0-9]\+\)/${{ env.version }}/g' mirrord.rb
sed -z -i -e 's/[0-9a-f]\{64\}/${{ env.sha256_mac }}/1' mirrord.rb
sed -z -i -e 's/[0-9a-f]\{64\}/${{ env.sha256_linux_aarch64 }}/2' mirrord.rb
sed -z -i -e 's/[0-9a-f]\{64\}/${{ env.sha256_linux_x86_64 }}/3' mirrord.rb
- name: Display formula (For debugging purposes only)
run: cat mirrord.rb
- name: Commit to metalbear-co/homebrew-mirrord
run: |
git config --global user.email "[email protected]"
git config --global user.name "Eyal Bukchin"
git add .
git commit -m "Update to ${{ env.version }}"
git push
update_latest:
needs: release_homebrew
runs-on: ubuntu-24.04
if: github.event_name != 'workflow_dispatch'
steps:
- name: Check out code
uses: actions/checkout@v4
with:
# Get complete history
fetch-depth: 0
- name: Update major version and latest tags
uses: metalbear-co/release-tracker-action@main
env:
# GitHub token to enable pushing tags
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Move "latest" tag
update-latest: true
# Don't update the vX.Y tags
update-minor: false