-
Notifications
You must be signed in to change notification settings - Fork 13
314 lines (282 loc) · 11.8 KB
/
deploy.console.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
name: Deploy - Console
on:
push:
branches:
- rc
- main
pull_request:
branches:
- rc
- main
workflow_dispatch:
permissions:
contents: write
env:
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
jobs:
setup:
runs-on: ubuntu-latest
outputs:
PURE_VERSION: ${{ steps.version.outputs.PURE_VERSION }}
VERSION: ${{ steps.version.outputs.VERSION }}
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get Version
id: version
working-directory: ./console
run: |
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
echo "PURE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
else
echo "VERSION=$(node -p "require('./package.json').version")-rc" >> $GITHUB_OUTPUT
echo "PURE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
fi
- name: Diff Changes
uses: dorny/paths-filter@v3
id: filter
with:
base: ${{ github.ref }}
filters: |
changed:
- "console/**"
- "pluto/**"
- "client/ts/**"
- "freighter/ts/**"
- "x/ts/**"
- ".github/workflows/deploy.console.yaml"
create-release:
runs-on: ubuntu-latest
if: github.event_name == 'push' && needs.setup.outputs.changed == 'true'
needs: setup
env:
VERSION: ${{ needs.setup.outputs.VERSION }}
outputs:
release_id: ${{ steps.create-release.outputs.result }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Create Release
id: create-release
uses: actions/github-script@v6
with:
script: |
const { data: releases } = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
})
const release = releases.find(r => r.tag_name === `console-v${process.env.VERSION}`)
if (release != null) return release.id
const { data: { id } } = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `console-v${process.env.VERSION}`,
name: `Synnax Console v${process.env.VERSION}`,
draft: false,
prerelease: false,
})
return id
build-tauri:
needs: setup
if: needs.setup.outputs.changed == 'true'
env:
SYNNAX_TS_ENV: prod
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
strategy:
fail-fast: false
matrix:
platform: [macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: MacOS - Import Apple Developer Certificate
# Only notarize on MacOS and on push events, not on PRs. This prevents excessive
# notarization requests and long CI times on PRs.
if: matrix.platform == 'macos-latest' && github.event_name == 'push'
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
security find-identity -v -p codesigning build.keychain
- name: MacOS - Verify Certificate
# Same as above - only notarize on MacOS and on push events, not on PRs
if: matrix.platform == 'macos-latest' && github.event_name == 'push'
run: |
CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application")
echo "Cert info"
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
echo "Certificate imported."
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Adjust Auto Updater URL for Release Candidate
if: github.event_name == 'push' && github.ref == 'refs/heads/rc'
working-directory: ./console/src-tauri
run: |
jq '.plugins.updater.endpoints = ["https://raw.githubusercontent.com/synnaxlabs/synnax/rc/console/release-spec.json"]' tauri.conf.json > temp.json
rm tauri.conf.json
mv temp.json tauri.conf.json
- name: Install Rust Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: console/src-tauri -> target
key: ${{ runner.os }}
- name: Turbo Cache
uses: actions/cache@v3
with:
path: .turbo-cache
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Install Dependencies
run: pnpm i
- name: Build Pluto
if: needs.setup.outputs.changed == 'true'
run: pnpm build:pluto
- name: Build Drift
if: needs.setup.outputs.changed == 'true'
run: pnpm build:drift
# We need to build the console separately WITHOUT turbo repo because of strange
# incompatibility issues with rust builds.
- name: Build Console
if: needs.setup.outputs.changed == 'true'
env:
NODE_OPTIONS: "--max_old_space_size=4096"
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
working-directory: ./console
run: pnpm build
- name: Upload MacOS Release Asset
if: github.event_name == 'push' && matrix.platform == 'macos-latest'
run: |
gh release upload --clobber console-v${{ needs.setup.outputs.VERSION }} ./console/src-tauri/target/release/bundle/macos/Synnax.app.tar.gz
gh release upload --clobber console-v${{ needs.setup.outputs.VERSION }} ./console/src-tauri/target/release/bundle/macos/Synnax.app.tar.gz.sig
gh release upload --clobber console-v${{ needs.setup.outputs.VERSION }} ./console/src-tauri/target/release/bundle/dmg/Synnax_${{ needs.setup.outputs.PURE_VERSION }}_aarch64.dmg
- name: Upload Windows Release Asset
if: github.event_name == 'push' && matrix.platform == 'windows-latest'
run: |
gh release upload --clobber console-v${{ needs.setup.outputs.VERSION }} ./console/src-tauri/target/release/bundle/msi/Synnax_${{ needs.setup.outputs.PURE_VERSION }}_x64_en-US.msi
gh release upload --clobber console-v${{ needs.setup.outputs.VERSION }} ./console/src-tauri/target/release/bundle/msi/Synnax_${{ needs.setup.outputs.PURE_VERSION }}_x64_en-US.msi.sig
gh release upload --clobber console-v${{ needs.setup.outputs.VERSION }} ./console/src-tauri/target/release/bundle/nsis/Synnax_${{ needs.setup.outputs.PURE_VERSION }}_x64-setup.exe
gh release upload --clobber console-v${{ needs.setup.outputs.VERSION }} ./console/src-tauri/target/release/bundle/nsis/Synnax_${{ needs.setup.outputs.PURE_VERSION }}_x64-setup.exe.sig
publish-release:
runs-on: ubuntu-latest
if: needs.setup.outputs.changed == 'true' && needs.create-release.outputs.release_id != ''
needs: [create-release, build-tauri, setup]
env:
VERSION: ${{ needs.setup.outputs.VERSION }}
PURE_VERSION: ${{ needs.setup.outputs.PURE_VERSION }}
RELEASE_ID: ${{ needs.create-release.outputs.release_id }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Publish Release
id: publish-release
uses: actions/github-script@v6
with:
script: |
github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: process.env.RELEASE_ID,
draft: false,
prerelease: false,
})
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Add Auto Update JSON File
id: auto-update-json-file
uses: actions/github-script@v6
env:
release_id: ${{ needs.create-release.outputs.release_id }}
with:
script: |
const fs = await import("fs");
const pureVersion = process.env.PURE_VERSION;
const version = process.env.VERSION;
const {
repo: { repo, owner },
} = context;
const baseURL = `https://github.com/${owner}/${repo}/releases/download/console-v${version}/`;
const darwinURL = baseURL + "Synnax.app.tar.gz";
const darwinSig = await github.request(`GET ${darwinURL}.sig`);
const windowsURL = baseURL + `Synnax_${pureVersion}_x64_en-US.msi`;
const windowsSig = await github.request(`GET ${windowsURL}.sig`);
const pub_date = new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
const ecd = new TextDecoder();
const data = {
version: `v${pureVersion}`,
notes: "Synnax Update",
pub_date,
platforms: {
"darwin-x86_64": {
signature: ecd.decode(darwinSig.data),
url: darwinURL,
},
"linux-x86_64": {
signature: "not_supported_and_tauri_requires_an_entry",
url: darwinURL,
},
"windows-x86_64": {
signature: ecd.decode(windowsSig.data),
url: windowsURL,
},
},
};
fs.writeFileSync("console/release-spec.json", JSON.stringify(data, null, 2));
- name: Commit & Push Auto Update JSON File on RC
id: commit-auto-update-json-file-rc
if: github.ref == 'refs/heads/rc'
uses: EndBug/add-and-commit@v9
with:
add: "*"
default_author: github_actor
message: "Auto Update JSON File"
pull: "--commit --no-edit"
push: "origin rc --force"
- name: Commit & Push Auto Update JSON File on Main
id: commit-auto-update-json-file-main
if: github.ref == 'refs/heads/main'
uses: EndBug/add-and-commit@v9
with:
add: "*"
default_author: github_actor
message: "Auto Update JSON File"
pull: "--commit --no-edit"
push: "origin main --force"