-
Notifications
You must be signed in to change notification settings - Fork 24
249 lines (209 loc) · 9.04 KB
/
build-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
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
name: Build Release
on:
release:
types: [created]
jobs:
build_linux:
strategy:
fail-fast: false
matrix:
platform:
- name: linux 64bit
os: ubuntu-latest
arch: x86_64-unknown-linux-musl
artifact: playit-linux-amd64
dpkg_arch: amd64
- name: linux arm64
os: ubuntu-latest
arch: aarch64-unknown-linux-musl
artifact: playit-linux-aarch64
dpkg_arch: arm64
- name: linux arm7
os: ubuntu-latest
arch: armv7-unknown-linux-gnueabihf
artifact: playit-linux-armv7
dpkg_arch: armhf
- name: linux 32bit
os: ubuntu-latest
arch: i686-unknown-linux-gnu
artifact: playit-linux-i686
dpkg_arch: i386
# - name: linux mipsel
# os: ubuntu-latest
# arch: mipsel-unknown-linux-musl
# artifact: playit-linux-mipsel
# dpkg_arch: mipsel
#
# - name: linux mips
# os: ubuntu-latest
# arch: mips-unknown-linux-musl
# artifact: playit-linux-mips
# dpkg_arch: mips
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v3
- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
- name: build release
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target ${{ matrix.platform.arch }} --release --all
- name: Upload Binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./target/${{ matrix.platform.arch }}/release/playit-cli
asset_name: ${{ matrix.platform.artifact }}
asset_content_type: application/octet-stream
- name: Package .deb
shell: bash
run: 'bash ./build-scripts/package-linux-deb.sh "./target/${{ matrix.platform.arch }}/release/playit-cli" ${{ matrix.platform.dpkg_arch }}'
- name: Upload .deb
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./target/deb/playit_${{ matrix.platform.dpkg_arch }}.deb
asset_name: playit_${{ matrix.platform.dpkg_arch }}.deb
asset_content_type: application/octet-stream
build_macos:
environment: production
strategy:
fail-fast: false
matrix:
platform:
- name: macos intel
os: macos-latest
arch: x86_64-apple-darwin
artifact: playit-darwin-intel
- name: macos arm
os: macos-latest
arch: aarch64-apple-darwin
artifact: playit-darwin-arm
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v3
- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.arch }}
- name: build release
uses: actions-rs/cargo@v1
with:
command: build
args: --target ${{ matrix.platform.arch }} --release --all
# reference: https://federicoterzi.com/blog/automatic-code-signing-and-notarization-for-macos-apps-using-github-actions/
- name: Codesign binary
# Extract the secrets we defined earlier as environment variables
env:
MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
run: |
# Turn our base64-encoded certificate back to a regular .p12 file
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
# We need to create a new keychain, otherwise using the certificate will prompt
# with a UI dialog asking for the certificate password, which we can't
# use in a headless CI environment
security create-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PWD" build.keychain
/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" --options runtime target/${{ matrix.platform.arch }}/release/playit-cli
- name: Notorize binary
env:
PROD_MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
PROD_MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
PROD_MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
run: |
echo "Create keychain profile"
xcrun notarytool store-credentials "notarytool-profile" --apple-id "$PROD_MACOS_NOTARIZATION_APPLE_ID" --team-id "$PROD_MACOS_NOTARIZATION_TEAM_ID" --password "$PROD_MACOS_NOTARIZATION_PWD"
# We can't notarize an app bundle directly, but we need to compress it as an archive.
# Therefore, we create a zip file containing our app bundle, so that we can send it to the
# notarization service
echo "Creating temp notarization archive"
ditto -c -k --keepParent "target/${{ matrix.platform.arch }}/release/playit-cli" "notarization.zip"
# Here we send the notarization request to the Apple's Notarization service, waiting for the result.
# This typically takes a few seconds inside a CI environment, but it might take more depending on the App
# characteristics. Visit the Notarization docs for more information and strategies on how to optimize it if
# you're curious
echo "Notarize app"
xcrun notarytool submit "notarization.zip" --keychain-profile "notarytool-profile"
# Finally, we need to "attach the staple" to our executable, which will allow our app to be
# validated by macOS even when an internet connection is not available.
# REMOVED: don't wait for notarization, takes too long
# echo "Attach staple"
# xcrun stapler staple "target/${{ matrix.platform.arch }}/release/playit-cli"
- name: Upload Binary
if: matrix.platform.os != 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./target/${{ matrix.platform.arch }}/release/playit-cli
asset_name: ${{ matrix.platform.artifact }}
asset_content_type: application/octet-stream
build_windows:
strategy:
fail-fast: false
matrix:
platform:
- name: windows 32bit
os: windows-latest
arch: i686-pc-windows-msvc
artifact: playit-windows-x86
- name: windows 64bit
os: windows-latest
arch: x86_64-pc-windows-msvc
artifact: playit-windows-x86_64
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v3
- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1
- name: Set path for candle and light
run: echo "C:\Program Files (x86)\WiX Toolset v3.11\bin" >> $GITHUB_PATH
shell: bash
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.arch }}
- run: cargo install cargo-wix
- run: cargo wix --target ${{ matrix.platform.arch }} --package playit-cli --nocapture --output=target/wix/${{ matrix.platform.artifact }}.msi
- name: Upload .exe
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./target/${{ matrix.platform.arch }}/release/playit-cli.exe
asset_name: ${{ matrix.platform.artifact }}.exe
asset_content_type: application/octet-stream
- name: Upload .msi
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./target/wix/${{ matrix.platform.artifact }}.msi
asset_name: ${{ matrix.platform.artifact }}.msi
asset_content_type: application/octet-stream