-
Notifications
You must be signed in to change notification settings - Fork 2
213 lines (183 loc) · 8.66 KB
/
release.yml
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
name: Release
on:
push:
tags: ['*']
# When making changes to this file, temporarily uncomment the next line to run the release
# workflow for your pull request. This will run additional steps prefixed with `Debugging` and
# attach the release artifacts to GHA workflow run Summary page, where you can download them for
# inspection.
# REMEMBER TO REVERT BACK THE CHANGE BEFORE LANDING YOUR PULL REQUEST!
# branches: ['*']
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
MACOSX_DEPLOYMENT_TARGET: 10.9
# Emit backtraces on panics.
RUST_BACKTRACE: 1
jobs:
github_build:
name: Build ${{ matrix.name }}
strategy:
fail-fast: false
matrix:
include:
# List of platforms, this must be in sync with the list of platforms in ci.yaml
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: linux-x64.tar.gz
# Build using `cross` to link against an older `glibc` version that's compatible
# with more Linux distros. When building on `ubuntu-latest`, we link against the
# latest glibc version, and `zinniad` cannot start e.g. in `node:18` Docker image
# based on Debian Bullseye distro.
builder: cross
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
name: linux-arm64.tar.gz
builder: cross
# Not supported by Deno yet, see
# https://github.com/denoland/rusty_v8/pull/999
# https://github.com/filecoin-station/zinnia/issues/178
# - target: x86_64-unknown-linux-musl
# os: ubuntu-latest
# name: linux-x64-musl.tar.gz
# builder: cross
# Not supported by Deno yet, see
# https://github.com/denoland/rusty_v8/issues/596
# https://github.com/filecoin-station/zinnia/issues/178
# - target: aarch64-unknown-linux-musl
# os: ubuntu-latest
# name: linux-arm64-musl.tar.gz
# builder: cross
- target: x86_64-apple-darwin
os: macos-latest
name: macos-x64.zip
- target: aarch64-apple-darwin
os: macos-latest
name: macos-arm64.zip
- target: x86_64-pc-windows-msvc
os: windows-latest
name: windows-x64.zip
runs-on: ${{ matrix.os }}
steps:
- name: Setup | Apple codesign
if: matrix.os == 'macos-latest'
env:
LOCAL_KEYCHAIN_PASSWORD: ${{ secrets.LOCAL_KEYCHAIN_PASSWORD }}
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
run: |
echo -n "$MACOS_CERTIFICATE" | base64 --decode -o certificate.p12
[ "$MACOS_CERTIFICATE_PASSWORD" = "" ] && echo "WARNING: Certificate passphrase is not set"
echo "Inspecting the signing certificate:"
openssl pkcs12 -info -in certificate.p12 -password "pass:$MACOS_CERTIFICATE_PASSWORD" -nokeys | head -7
echo "Setting up keychain for codesign"
security create-keychain -p "$LOCAL_KEYCHAIN_PASSWORD" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "$LOCAL_KEYCHAIN_PASSWORD" build.keychain
security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$LOCAL_KEYCHAIN_PASSWORD" build.keychain
security list-keychain -d user -s build.keychain
- name: Setup | Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false # caching requires a go.sum file, which we don't have in our project
- name: Setup | Rust
uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1
with:
toolchain: stable
target: ${{ matrix.target }}
- name: Setup | Cross
if: ${{ matrix.builder == 'cross' }}
run: |
curl -L https://github.com/cross-rs/cross/releases/latest/download/cross-x86_64-unknown-linux-gnu.tar.gz -o /tmp/cross.tgz
tar xzf /tmp/cross.tgz -C ~/.cargo/bin
cross --version
# When debugging this workflow, cache the build artefacts
# Note that a build for one tag cannot access cache created by a build for a different tag,
# therefore caching does not work for real release builds.
- name: Debugging | Cache Rust deps
uses: Swatinem/rust-cache@3cf7f8cc28d1b4e7d01e3783be10a97d55d483c8 # v2.7.1
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
with:
shared-key: release-${{ matrix.target }}
cache-on-failure: true
# On Windows, Lassie build script copies golassie.dll to the target directory. When
# Swatinem/rust-cache loads cached data, it does not restore that DLL file. To fix the
# problem, we remove the cached Lassie version to force `cargo build` to re-run the build
# script, which will copy `golassie.dll`.
- name: Debugging | Force rebuild of Lassie
if: ${{ !startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows-latest' }}
run: cargo clean --release --target ${{ matrix.target }} -p lassie
- name: Build | Build
run: ${{ matrix.builder || 'cargo' }} build --release --locked --target ${{ matrix.target }}
- name: Post Build | Prepare artifacts [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
dir
7z a ../../../zinnia-${{ matrix.name }} zinnia.exe golassie.dll
7z a ../../../zinniad-${{ matrix.name }} zinniad.exe golassie.dll
- name: Post Build | Prepare artifacts [Linux]
if: matrix.os == 'ubuntu-latest'
run: |
cd target/${{ matrix.target }}/release
tar czvf ../../../zinnia-${{ matrix.name }} zinnia
tar czvf ../../../zinniad-${{ matrix.name }} zinniad
- name: Post Build | Sign the executables [macOS]
if: matrix.os == 'macos-latest'
env:
LOCAL_KEYCHAIN_PASSWORD: ${{ secrets.LOCAL_KEYCHAIN_PASSWORD }}
MACOS_SIGNING_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }}
MACOS_APP_ID: io.filstation.zinnia
run: |
# Unlock the keychain again. Our builds take several minutes to complete,
# which usually triggers a timeout that locks the keychain.
security unlock-keychain -p "$LOCAL_KEYCHAIN_PASSWORD" build.keychain
# Sign `zinnia`
codesign --timestamp --force --verbose \
--options runtime \
--entitlements build/entitlements.mac.plist \
--sign "$MACOS_SIGNING_IDENTITY" \
--identifier "$MACOS_APP_ID" \
target/${{ matrix.target }}/release/zinnia
# Sign `zinniad`
codesign --timestamp --force --verbose \
--options runtime \
--entitlements build/entitlements.mac.plist \
--sign "$MACOS_SIGNING_IDENTITY" \
--identifier "$MACOS_APP_ID" \
target/${{ matrix.target }}/release/zinniad
- name: Post Build | Prepare artifacts [macOS]
if: matrix.os == 'macos-latest'
run: |
cd target/${{ matrix.target }}/release
zip ../../../zinnia-${{ matrix.name }} zinnia
zip ../../../zinniad-${{ matrix.name }} zinniad
- name: Post Build | Notarize the executables [macOS]
if: matrix.os == 'macos-latest'
run: |
xcrun notarytool submit zinnia-${{ matrix.name }} --wait \
--apple-id ${{ secrets.APPLE_ID }} \
--password ${{ secrets. APPLE_ID_PASSWORD }} \
--team-id ${{ secrets.APPLE_TEAM_ID }}
xcrun notarytool submit zinniad-${{ matrix.name }} --wait \
--apple-id ${{ secrets.APPLE_ID }} \
--password ${{ secrets. APPLE_ID_PASSWORD }} \
--team-id ${{ secrets.APPLE_TEAM_ID }}
- name: Release | Upload artifacts
if: startsWith(github.ref, 'refs/tags/') # Don't create releases when debugging
uses: softprops/action-gh-release@c9b46fe7aad9f02afd89b12450b780f52dacfb2d
with:
draft: true
files: "*-${{ matrix.name }}"
fail_on_unmatched_files: true
# When debugging this workflow, attach the artifacts to the workflow run
- name: Debugging | Upload artifacts to workflow run
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v3
with:
name: archives-${{ matrix.name }}
path: "*-${{ matrix.name }}"