forked from thomasrockhu-codecov/graphql-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
445 lines (377 loc) · 15.5 KB
/
release.yml
File metadata and controls
445 lines (377 loc) · 15.5 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
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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
name: 🚀 Release
on:
push:
tags:
- "16.*"
permissions:
id-token: write
contents: read
jobs:
release:
name: 📦 Build & Publish NuGet Packages
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: 📦 Checkout
uses: actions/checkout@v4
with:
show-progress: false
- name: 🛠 Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.x
9.x
10.x
- name: 🏷 Get the version from tag
run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: 📦 Build NuGet Packages
run: |
./build.sh pack --SemVersion ${{ env.GIT_TAG }} --Configuration Release
env:
NitroApiClientId: ${{ secrets.NITRO_API_CLIENT_ID }}
NitroIdentityClientId: ${{ secrets.NITRO_IDENTITY_CLIENT_ID }}
NitroIdentityScopes: ${{ secrets.NITRO_IDENTITY_SCOPES }}
- name: 📦 Publish Nitro CLI client
run: |
./build.sh UploadNitroClient --SemVersion ${{ env.GIT_TAG }}
./build.sh PublishNitroClient --SemVersion ${{ env.GIT_TAG }}
env:
NitroApiClientId: ${{ secrets.NITRO_API_CLIENT_ID }}
NitroApiKey: ${{ secrets.NITRO_API_KEY }}
- name: 🚀 Push Packages to NuGet
run: |
./build.cmd publish --skip
env:
NuGetApiKey: ${{ secrets.NUGETAPIKEY }}
- name: 📤 Attach .nupkg assets to GitHub release
run: |
for file in ./output/packages/*.nupkg; do
echo "📤 Uploading $file"
gh release upload ${{ env.GIT_TAG }} "$file" --repo "${{ github.repository }}"
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-nitro-cli:
name: 🧱 Build and Publish Nitro CLI
runs-on: ${{ matrix.os }}
# We need to depend on this job, as it publishes the persisted operations of the CLI.
needs: [release]
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
strategy:
matrix:
include:
# Linux (x64)
- os: ubuntu-22.04
rid: linux-x64
- os: ubuntu-22.04
rid: linux-musl-x64
# Linux (arm64 on ARM runner!)
- os: ubuntu-24.04-arm
rid: linux-arm64
# macOS
- os: macos-15
rid: osx-x64
- os: macos-15
rid: osx-arm64
# Windows
- os: windows-2025
rid: win-x64
- os: windows-2025
rid: win-x86
# Windows (arm64 on ARM runner!)
# - os: windows-11-arm
# rid: win-arm64
steps:
- name: 📦 Checkout
uses: actions/checkout@v4
- name: 🛠 Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.x
- name: 🏷 Get the version from tag (Windows)
if: runner.os == 'Windows'
run: echo "GIT_TAG=$($env:GITHUB_REF -replace '^refs/tags/','')" >> $env:GITHUB_ENV
shell: pwsh
- name: 🏷 Get the version from tag (Unix)
if: runner.os != 'Windows'
run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
shell: bash
- name: 📦 Publish binary (Windows)
if: runner.os == 'Windows'
run: |
./build.ps1 publishaot --SemVersion $env:GIT_TAG --RuntimeIdentifier ${{ matrix.rid }} --Configuration Release
shell: pwsh
env:
NitroApiClientId: ${{ secrets.NITRO_API_CLIENT_ID }}
NitroIdentityClientId: ${{ secrets.NITRO_IDENTITY_CLIENT_ID }}
NitroIdentityScopes: ${{ secrets.NITRO_IDENTITY_SCOPES }}
- name: 📦 Publish binary (Unix)
if: runner.os != 'Windows'
run: |
./build.sh publishaot --SemVersion $GIT_TAG --RuntimeIdentifier ${{ matrix.rid }} --Configuration Release
shell: bash
env:
NitroApiClientId: ${{ secrets.NITRO_API_CLIENT_ID }}
NitroIdentityClientId: ${{ secrets.NITRO_IDENTITY_CLIENT_ID }}
NitroIdentityScopes: ${{ secrets.NITRO_IDENTITY_SCOPES }}
- name: 🖋️ Azure login (Windows)
uses: azure/login@v1
if: runner.os == 'Windows'
with:
creds: ${{ secrets.SIGNING_CREDENTIALS }}
- name: 🖋️ Sign binary (Windows)
uses: azure/trusted-signing-action@v0
if: runner.os == 'Windows'
with:
endpoint: ${{ vars.AZURE_TRUSTED_SIGNING_ACCOUNT_ENDPOINT }}
trusted-signing-account-name: ${{ secrets.AZURE_CODE_SIGNING_NAME }}
certificate-profile-name: ${{ secrets.WINDOWS_APP_CERT_PROFILE_NAME }}
files: ${{ github.workspace }}\publish\nitro.exe
file-digest: SHA256
timestamp-rfc3161: http://timestamp.acs.microsoft.com
timestamp-digest: SHA256
exclude-environment-credential: true
exclude-workload-identity-credential: true
exclude-managed-identity-credential: true
exclude-shared-token-cache-credential: true
exclude-visual-studio-credential: true
exclude-visual-studio-code-credential: true
exclude-azure-cli-credential: false
exclude-azure-powershell-credential: true
exclude-azure-developer-cli-credential: true
exclude-interactive-browser-credential: true
# https://docs.github.com/en/actions/how-tos/deploy/deploy-to-third-party-platforms/sign-xcode-applications
- name: 🖋️ Setup signing resources (macOS)
if: runner.os == 'macOS'
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.APPLE_DEVELOPER_CERTFICATE_BASE64 }}
P12_PASSWORD: ${{ secrets.APPLE_DEVELOPER_CERTFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.TEMPORARY_KEYCHAIN_PASSWORD }}
run: |
# create variables
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# import certificate from secrets
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
# create temporary keychain
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# import certificate to keychain
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
- name: 🖋️ Sign binary (macOS)
if: runner.os == 'macOS'
env:
CODESIGN_IDENTITY: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_IDENTITY }}
run: |
echo "Code signing 'publish/nitro'..."
codesign --sign "$CODESIGN_IDENTITY" \
--verbose=3 \
--identifier "com.chillicream.nitro" \
--options runtime \
--timestamp \
--force \
publish/nitro
codesign --verify --deep --strict --verbose=2 publish/nitro
- name: 📦 Zip binary (Windows)
if: runner.os == 'Windows'
run: |
Compress-Archive -Path (Get-Item publish/nitro.exe) -DestinationPath nitro-${{ matrix.rid }}.zip
shell: pwsh
- name: 📦 Zip binary (Unix)
if: runner.os != 'Windows'
run: |
zip -j nitro-${{ matrix.rid }}.zip publish/nitro
shell: bash
- name: 🖋️ Notarize binary (macOS)
if: runner.os == 'macOS'
env:
CODESIGN_IDENTITY: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_IDENTITY }}
APPLE_DEVELOPER_ID_EMAIL: ${{ secrets.APPLE_DEVELOPER_ID_EMAIL }}
APPLE_DEVELOPER_TEAM_ID: ${{ secrets.APPLE_DEVELOPER_TEAM_ID }}
APPLE_DEVELOPER_NITRO_CLI_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_DEVELOPER_NITRO_CLI_APP_SPECIFIC_PASSWORD }}
run: |
echo "Code signing 'nitro-${{ matrix.rid }}.zip'..."
codesign --sign "$CODESIGN_IDENTITY" \
--verbose=3 \
--options runtime \
--timestamp \
--force \
nitro-${{ matrix.rid }}.zip
codesign --verify --deep --strict --verbose=2 nitro-${{ matrix.rid }}.zip
echo "Notarizing 'nitro-${{ matrix.rid }}.zip'..."
xcrun notarytool submit nitro-${{ matrix.rid }}.zip \
--apple-id "$APPLE_DEVELOPER_ID_EMAIL" \
--team-id "$APPLE_DEVELOPER_TEAM_ID" \
--password "$APPLE_DEVELOPER_NITRO_CLI_APP_SPECIFIC_PASSWORD" \
--wait
spctl --assess --type exec -vv nitro-${{ matrix.rid }}.zip || true
codesign -dvv nitro-${{ matrix.rid }}.zip || true
- name: 🖋️ Clean up signing resources (macOS)
if: always() && runner.os == 'macOS'
run: |
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
- name: 📤 Upload zipped binary as artifact
uses: actions/upload-artifact@v4
with:
name: nitro-${{ matrix.rid }}
path: nitro-${{ matrix.rid }}.zip
- name: 📤 Attach zipped binary to GitHub release
shell: bash
run: |
gh release upload ${{ github.ref_name }} nitro-${{ matrix.rid }}.zip --repo ${{ github.repository }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-nitro-cli-npm:
name: 🧱 Publish Nitro CLI to npm
runs-on: ubuntu-latest
needs: [build-nitro-cli]
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: 📦 Checkout
uses: actions/checkout@v4
- name: 🧰 Setup Node
uses: actions/setup-node@v4
with:
node-version: "22.x"
registry-url: ${{ vars.NPM_REGISTRY_URL }}
scope: "@chillicream"
- name: 🧰 Enable corepack
run: corepack enable
- name: 📥 Download all zipped nitro binaries
uses: actions/download-artifact@v4
with:
pattern: nitro-*
merge-multiple: true
path: dist-zips
- name: 🏷 Get the version from tag
run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: 🗂️ Move binaries to npm package
run: |
PACKAGE_DIR="src/Nitro/CommandLine/src/chillicream-nitro"
for z in dist-zips/nitro-*.zip; do
name=$(basename "$z" .zip) # e.g. nitro-linux-x64
rid=${name#nitro-} # e.g. linux-x64
echo "Unpacking $z -> $PACKAGE_DIR/$rid"
mkdir -p "$PACKAGE_DIR/$rid"
unzip -q "$z" -d "$PACKAGE_DIR/$rid"
done
# Ensure unix binaries are executable
chmod +x $PACKAGE_DIR/linux-x64/nitro || true
chmod +x $PACKAGE_DIR/linux-musl-x64/nitro || true
chmod +x $PACKAGE_DIR/linux-arm64/nitro || true
chmod +x $PACKAGE_DIR/osx-x64/nitro || true
chmod +x $PACKAGE_DIR/osx-arm64/nitro || true
# Ensure cli.js is executable
chmod +x $PACKAGE_DIR/cli.js
- name: 🔍 Install dependencies
working-directory: src/Nitro/CommandLine/src/chillicream-nitro
run: yarn install --immutable
- name: 🏷️ Set version
working-directory: src/Nitro/CommandLine/src/chillicream-nitro
run: npm version $GIT_TAG
- name: 📦 Create tarball
working-directory: src/Nitro/CommandLine/src/chillicream-nitro
run: npm pack
- name: 🚀 Publish tarball to npm
working-directory: src/Nitro/CommandLine/src/chillicream-nitro
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
run: |
TARBALL="chillicream-nitro-${GIT_TAG}.tgz"
if [[ "$GIT_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
DIST_TAG="latest"
else
DIST_TAG="preview"
fi
npm publish "./${TARBALL}" --access public --registry=${{ vars.NPM_REGISTRY_URL }} --tag "${DIST_TAG}"
shell: bash
- name: 📤 Upload tarball as artifact
uses: actions/upload-artifact@v4
with:
name: chillicream-nitro-${{ env.GIT_TAG }}.tgz
path: src/Nitro/CommandLine/src/chillicream-nitro/chillicream-nitro-${{ env.GIT_TAG }}.tgz
- name: 📤 Attach tarball to GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: src/Nitro/CommandLine/src/chillicream-nitro
run: |
gh release upload "${{ github.ref_name }}" "chillicream-nitro-${{ github.ref_name }}.tgz" --repo "${{ github.repository }}"
update-homebrew:
name: 🍺 Update Homebrew Formula
runs-on: ubuntu-latest
needs: [build-nitro-cli]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: 📥 Checkout main repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🏷️ Get release version
id: version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: ⬇️ Download macOS ARM64 release
run: |
curl -L -o nitro-osx-arm64.zip \
"https://github.com/ChilliCream/graphql-platform/releases/download/${{ steps.version.outputs.version }}/nitro-osx-arm64.zip"
- name: ⬇️ Download macOS x64 release
run: |
curl -L -o nitro-osx-x64.zip \
"https://github.com/ChilliCream/graphql-platform/releases/download/${{ steps.version.outputs.version }}/nitro-osx-x64.zip"
- name: 🔢 Calculate SHA256 hashes
id: hashes
run: |
ARM64_SHA=$(sha256sum nitro-osx-arm64.zip | cut -d' ' -f1)
X64_SHA=$(sha256sum nitro-osx-x64.zip | cut -d' ' -f1)
echo "arm64_sha=$ARM64_SHA" >> $GITHUB_OUTPUT
echo "x64_sha=$X64_SHA" >> $GITHUB_OUTPUT
echo "🔍 ARM64 SHA: $ARM64_SHA"
echo "🔍 X64 SHA: $X64_SHA"
- name: 📝 Generate Homebrew formula
run: |
cat > nitro-cli.rb << EOF
class NitroCli < Formula
desc "ChilliCream Nitro Command Line"
homepage "https://chillicream.com"
url "https://github.com/ChilliCream/graphql-platform"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "https://github.com/ChilliCream/graphql-platform/releases/download/${{ steps.version.outputs.version }}/nitro-osx-arm64.zip"
sha256 "${{ steps.hashes.outputs.arm64_sha }}"
else
url "https://github.com/ChilliCream/graphql-platform/releases/download/${{ steps.version.outputs.version }}/nitro-osx-x64.zip"
sha256 "${{ steps.hashes.outputs.x64_sha }}"
end
end
def install
bin.install "nitro"
end
test do
system "#{bin}/nitro", "--version"
end
end
EOF
- name: 📥 Checkout homebrew repo
uses: actions/checkout@v4
with:
repository: ChilliCream/homebrew-tools
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tools
- name: 🚀 Update formula in homebrew repo
run: |
cp nitro-cli.rb homebrew-tools/nitro-cli.rb
cd homebrew-tools
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add nitro-cli.rb
git commit -m "🍺 Update nitro formula to ${{ steps.version.outputs.version }}" || exit 0
git push