-
Notifications
You must be signed in to change notification settings - Fork 85
410 lines (347 loc) · 15.8 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
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
name: Release
on:
push:
tags:
- "v*" # Run when tag matches v*, i.e. v1.0, v20.15.10
env:
RELEASE_BIN: rover
RELEASE_DIR: artifacts
GITHUB_REF: "${{ github.ref }}"
WINDOWS_TARGET: x86_64-pc-windows-msvc
MACOS_TARGET: x86_64-apple-darwin
LINUX_GNU_TARGET: x86_64-unknown-linux-gnu
LINUX_MUSL_TARGET: x86_64-unknown-linux-musl
# Space separated paths to include in the archive.
RELEASE_ADDS: README.md LICENSE
APPLE_TEAM_ID: "YQK948L752"
APPLE_USERNAME: "[email protected]"
jobs:
build:
name: Build artifacts
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux-gnu, linux-musl, macos, windows]
include:
- build: linux-gnu
os: ubuntu-16.04
rust: stable
- build: linux-musl
os: ubuntu-latest
rust: stable
- build: macos
os: macos-latest
rust: stable
- build: windows
os: windows-latest
rust: stable
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- uses: actions/checkout@v2
- name: Query version number
id: get_version
shell: bash
run: |
echo "using version tag ${GITHUB_REF:10}"
echo ::set-output name=version::"${GITHUB_REF:10}"
- name: Install Node and npm
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install Rust
if: matrix.rust
run: |
rustup update ${{ matrix.rust }} --no-self-update
rustup default ${{ matrix.rust }}
- name: Install p7zip (MacOS)
if: matrix.build == 'macos'
run: brew install p7zip
- name: Install musl-tools (MUSL Linux)
if: matrix.build == 'linux-musl'
run: |
sudo apt update
sudo apt install musl-tools
- name: Build (GNU Linux)
if: matrix.build == 'linux-gnu'
run: |
rustup target add ${{ env.LINUX_GNU_TARGET }}
cargo build --release --target ${{ env.LINUX_GNU_TARGET }}
- name: Build (MUSL Linux)
if: matrix.build == 'linux-musl'
run: |
rustup target add ${{ env.LINUX_MUSL_TARGET }}
cargo build --release --no-default-features --target ${{ env.LINUX_MUSL_TARGET }}
- name: Build (MacOS)
if: matrix.build == 'macos'
run: cargo build --release
- name: Build (Windows)
if: matrix.build == 'windows'
run: cargo build --release
env:
RUSTFLAGS: -Ctarget-feature=+crt-static # fully static build
- name: Populate artifact directory
shell: bash
run: |
mkdir ${{ env.RELEASE_DIR }} dist
mv ${{ env.RELEASE_ADDS }} ./dist
- name: Move binary to dist (MacOS)
if: matrix.build == 'macos'
shell: bash
run: mv ./target/release/${{ env.RELEASE_BIN }} ./dist/${{ env.RELEASE_BIN }}
- name: Create tarball (GNU Linux)
if: matrix.build == 'linux-gnu'
run: |
mv ./target/${{ env.LINUX_GNU_TARGET }}/release/${{ env.RELEASE_BIN }} ./dist/${{ env.RELEASE_BIN }}
7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.version }}-${{ env.LINUX_GNU_TARGET }}.tar.gz
- name: Create tarball (MUSL Linux)
if: matrix.build == 'linux-musl'
run: |
mv ./target/${{ env.LINUX_MUSL_TARGET }}/release/${{ env.RELEASE_BIN }} ./dist/${{ env.RELEASE_BIN }}
7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.version }}-${{ env.LINUX_MUSL_TARGET }}.tar.gz
- name: Create tarball (Windows)
if: matrix.build == 'windows'
shell: bash
run: |
mv ./target/release/${{ env.RELEASE_BIN }}.exe ./dist/${{ env.RELEASE_BIN }}.exe
7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.version }}-${{ env.WINDOWS_TARGET }}.tar.gz
- name: Create build keychain (MacOS)
if: matrix.build == 'macos'
run: |
security create-keychain -p ${{ secrets.MACOS_KEYCHAIN_PASSWORD }} build.keychain
security default-keychain -s build.keychain
- name: Unlock build keychain (MacOS)
if: matrix.build == 'macos'
run: |
security unlock-keychain -p ${{ secrets.MACOS_KEYCHAIN_PASSWORD }} build.keychain
- name: Import codesigning certificate to build keychain (MacOS)
if: matrix.build == 'macos'
run: |
echo ${{ secrets.MACOS_CERT_BUNDLE_BASE64 }} | base64 --decode > certificate.p12
security import certificate.p12 -k build.keychain -P ${{ secrets.MACOS_CERT_BUNDLE_PASSWORD }} -T /usr/bin/codesign
- name: Verify keychain is set up correctly MacOS
if: matrix.build == 'macos'
run: security find-identity -v
# This prevents a UI password prompt we cannot access in CI
- name: Add the codesign tool to the security partition-list (MacOS)
if: matrix.build == 'macos'
run: |
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k ${{ secrets.MACOS_KEYCHAIN_PASSWORD }} build.keychain
- name: Codesign (MacOS)
if: matrix.build == 'macos'
run: |
/usr/bin/codesign \
--sign ${{ env.APPLE_TEAM_ID }} \
--options runtime \
--entitlements ./macos-entitlements.plist \
--force \
--timestamp \
./dist/${{ env.RELEASE_BIN }} \
-v
/usr/bin/codesign -vvv --deep --strict ./dist/${{ env.RELEASE_BIN }}
- name: Prepare zip for notarization (MacOS)
if: matrix.build == 'macos'
run: |
ditto -c -k --keepParent ./dist "rover-${{ steps.get_version.outputs.version }}.zip"
- name: Begin notarization process (MacOS)
if: matrix.build == 'macos'
id: begin_notarize
run: |
NOTARIZE_JSON=$(
xcrun altool \
--notarize-app \
--primary-bundle-id com.apollographql.rover \
--username ${{ env.APPLE_USERNAME }} \
--asc-provider ${{ env.APPLE_TEAM_ID }} \
--password ${{ secrets.MACOS_NOTARIZATION_PASSWORD }} \
--file ./rover-${{ steps.get_version.outputs.version }}.zip \
--output-format json)
echo "::set-output name=NOTARIZE_JSON::$NOTARIZE_JSON"
- name: Parse notarization output (MacOS)
if: matrix.build == 'macos'
id: parse_notarize
run: |
SUCCESS_MESSAGE=$(
cat <<EOM | jq -r -e '.["success-message"]'
${{ steps.begin_notarize.outputs.NOTARIZE_JSON }}
EOM
)
echo "::debug::$SUCCESS_MESSAGE"
REQUEST_UUID=$(
cat <<EOM | jq -r -e '.["notarization-upload"].RequestUUID'
${{ steps.begin_notarize.outputs.NOTARIZE_JSON }}
EOM
)
echo "::debug::$REQUEST_UUID"
echo ::set-output name=SUCCESS_MESSAGE::$SUCCESS_MESSAGE
echo ::set-output name=REQUEST_UUID::$REQUEST_UUID
- name: Check notarization status (MacOS)
if: matrix.build == 'macos'
run: |
RETRY_MINUTES=10
RETRY_AFTER_SECONDS=30
MAX_RETRY_ATTEMPTS=$(($RETRY_MINUTES*60/$RETRY_AFTER_SECONDS))
for (( i = 0; i < $MAX_RETRY_ATTEMPTS; i++ )); do
xcrun altool \
--notarization-info '${{ steps.parse_notarize.outputs.REQUEST_UUID }}' \
--username '${{ env.APPLE_USERNAME }}' \
--password '${{ secrets.MACOS_NOTARIZATION_PASSWORD }}' \
--output-format json > notarization_status_$i.json
echo "::debug::$(cat notarization_status_$i.json)"
NOTARIZATION_STATUS=$(cat notarization_status_$i.json | jq -r -e '.["notarization-info"].Status')
echo "::debug::$NOTARIZATION_STATUS"
if [[ "$NOTARIZATION_STATUS" == "success" ]]; then
echo "Notarization successful."
exit 0
elif [[ "$NOTARIZATION_STATUS" == "in progress" ]]; then
echo "::debug::Trying again after $RETRY_AFTER_SECONDS seconds."
sleep $RETRY_AFTER_SECONDS
else
echo "::debug::Invalid notarization status."
exit 1
fi
done
echo "::debug::Notarization timed out after $RETRY_MINUTES minutes."
exit 1
- name: Create tarball (MacOS)
if: matrix.build == 'macos'
run: |
7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.version }}-${{ env.MACOS_TARGET }}.tar.gz
- name: Upload Tarball
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.build }}
path: ./${{ env.RELEASE_DIR }}
release:
name: GitHub Release
needs: build
runs-on: ubuntu-latest
env:
npm-dir: ./installers/npm
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
is-prerelease: ${{ contains(needs.build.outputs.version, 'alpha') || contains(needs.build.outputs.version, 'beta') || contains(needs.build.outputs.version, 'rc')|| contains(needs.build.outputs.version, 'test')}}
steps:
- uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
- name: Unzip binaries
shell: bash
run: |
tar -xzvf ./linux/${{ env.RELEASE_BIN }}-${{ needs.build.outputs.version }}-${{ env.LINUX_GNU_TARGET }}.tar.gz && mv ./dist/${{ env.RELEASE_BIN }} ./linux-gnu-cli && rm -rf dist
tar -xzvf ./linux/${{ env.RELEASE_BIN }}-${{ needs.build.outputs.version }}-${{ env.LINUX_MUSL_TARGET }}.tar.gz && mv ./dist/${{ env.RELEASE_BIN }} ./linux-musl-cli && rm -rf dist
tar -xzvf ./windows/${{ env.RELEASE_BIN }}-${{ needs.build.outputs.version }}-${{ env.WINDOWS_TARGET }}.tar.gz && mv ./dist/${{ env.RELEASE_BIN }}.exe ./windows-cli.exe && rm -rf dist
tar -xzvf ./macos/${{ env.RELEASE_BIN }}-${{ needs.build.outputs.version }}-${{ env.MACOS_TARGET }}.tar.gz && mv ./dist/${{ env.RELEASE_BIN }} ./macos-cli && rm -rf dist
- name: Hash binaries
id: get_shas
shell: bash
run: |
echo ::set-output name=linux-gnu-sha::"$(sha256sum -b linux-gnu-cli | cut -d ' ' -f1)"
echo ::set-output name=linux-musl-sha::"$(sha256sum -b linux-musl-cli | cut -d ' ' -f1)"
echo ::set-output name=windows-sha::"$(sha256sum -b windows-cli.exe | cut -d ' ' -f1)"
echo ::set-output name=macos-sha::"$(sha256sum -b macos-cli | cut -d ' ' -f1)"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.build.outputs.version }}
release_name: ${{ needs.build.outputs.version }}
prerelease: ${{ env.is-prerelease }}
body: |
<!---
paste the changelog entry here!
-->
---
This release was automatically created by [Github Actions](./.github/workflows/release.yml).
If you would like to verify that the binary you have downloaded was built from the source code
in this repository, you can compare the output of the commands below to the output of the same
commands on your machine.
#### MacOS
Binaries built for MacOS are signed and notarized, and are automatically verified with [Gatekeeper](https://support.apple.com/guide/deployment-reference-macos/using-gatekeeper-apd02b925e38/web).
Manual Verification:
```console
$ sha256sum -b $(which rover) | cut -d ' ' -f1
${{ steps.get_shas.outputs.macos-sha }}
```
#### GNU Linux
Manual Verification:
```console
$ sha256sum -b $(which rover) | cut -d ' ' -f1
${{ steps.get_shas.outputs.linux-gnu-sha }}
```
#### MUSL Linux
Manual Verification:
```console
$ sha256sum -b $(which rover) | cut -d ' ' -f1
${{ steps.get_shas.outputs.linux-musl-sha }}
```
#### Windows
Manual Verification:
```powershell
PS> Get-Command rover
CommandType Name Version Source
----------- ---- ------- ------
Application rover.exe 0.0.0.0 C:\Users\username\.rover\bin\rover.exe
PS> Get-FileHash C:\Users\username\.rover\bin\rover.exe
Algorithm Hash Path
--------- ---- ----
SHA256 ${{ steps.get_shas.outputs.windows-sha }} C:\Users\username\.rover\bin\rover.exe
```
- name: Release Linux GNU tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./linux-gnu/rover-${{ needs.build.outputs.version }}-${{ env.LINUX_GNU_TARGET }}.tar.gz
asset_content_type: application/gzip
asset_name: rover-${{ needs.build.outputs.version }}-${{ env.LINUX_GNU_TARGET }}.tar.gz
- name: Release Linux MUSL tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./linux-musl/rover-${{ needs.build.outputs.version }}-${{ env.LINUX_MUSL_TARGET }}.tar.gz
asset_content_type: application/gzip
asset_name: rover-${{ needs.build.outputs.version }}-${{ env.LINUX_MUSL_TARGET }}.tar.gz
- name: Release Windows tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./windows/rover-${{ needs.build.outputs.version }}-${{ env.WINDOWS_TARGET }}.tar.gz
asset_content_type: application/gzip
asset_name: rover-${{ needs.build.outputs.version }}-${{ env.WINDOWS_TARGET }}.tar.gz
- name: Release MacOS tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./macos/rover-${{ needs.build.outputs.version }}-${{ env.MACOS_TARGET }}.tar.gz
asset_content_type: application/gzip
asset_name: rover-${{ needs.build.outputs.version }}-${{ env.MACOS_TARGET }}.tar.gz
- name: Set up .npmrc
uses: actions/setup-node@v2
with:
node-version: ${{ env.node-version }}
registry-url: ${{ env.registry-url }}
- name: Install npm dependencies
working-directory: ${{ env.npm-dir }}
run: npm ci
- name: Publish to npm (stable)
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ env.is-prerelease == 'false' }}
working-directory: ${{ env.npm-dir }}
run: npm publish
- name: Publish to npm (prerelease)
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: ${{ env.is-prerelease == 'true' }}
working-directory: ${{ env.npm-dir }}
run: npm publish --tag beta