-
Notifications
You must be signed in to change notification settings - Fork 4
238 lines (213 loc) · 8.23 KB
/
build.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
name: Build and Release
run-name: Build ${{ github.run_number }} of branch ${{ github.ref_name }} by @${{ github.actor }}
on:
workflow_dispatch:
jobs:
# -----------------------------------------------------------------
# PREPARE
# -----------------------------------------------------------------
prepare:
name: Prepare Release
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
outputs:
pkg_version: ${{ steps.semver.outputs.nextStrict }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Next Version
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: main
patchAll: true
skipInvalidTags: true
- name: Create Draft Release
uses: ncipollo/[email protected]
with:
prerelease: true
draft: false
commit: ${{ github.sha }}
tag: ${{ steps.semver.outputs.nextStrict }}
name: ${{ steps.semver.outputs.nextStrict }}
body: '*pending*'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate CHANGELOG
id: changelog
uses: Requarks/changelog-action@v1
with:
token: ${{ github.token }}
fromTag: ${{ steps.semver.outputs.nextStrict }}
toTag: ${{ steps.semver.outputs.current }}
writeToFile: false
- name: Update Release Body
uses: ncipollo/[email protected]
with:
prerelease: true
updateOnlyUnreleased: true
allowUpdates: true
commit: ${{ github.sha }}
tag: ${{ steps.semver.outputs.nextStrict }}
name: ${{ steps.semver.outputs.nextStrict }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ secrets.GITHUB_TOKEN }}
# -----------------------------------------------------------------
# BUILD ELECTRON
# -----------------------------------------------------------------
build-electron:
name: Build Electron
needs: [prepare]
runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: write
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: linux
- os: macos-latest
platform: darwin
- os: windows-latest
platform: win32
env:
PKG_VERSION: ${{needs.prepare.outputs.pkg_version}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: macOS - Fetch Secrets from Vault
if: ${{ matrix.platform == 'darwin' }}
uses: hashicorp/[email protected]
with:
method: jwt
url: ${{ secrets.VAULT_URL }}
role: ${{ secrets.VAULT_ROLE }}
secrets: |
kv/data/draftforge/apple API_ISSUER_ID | APPLE_API_ISSUER ;
kv/data/draftforge/apple API_KEY_ID | APPLE_API_KEY_ID ;
kv/data/draftforge/apple API_KEY_P8 | API_KEY_P8 ;
kv/data/draftforge/apple DIST_CERT_P12 | CSC_LINK ;
kv/data/draftforge/apple DIST_CERT_P12_PWD | CSC_KEY_PASSWORD ;
- name: macOS - Save signing certs
if: ${{ matrix.platform == 'darwin' }}
run: |
mkdir -p private_keys
echo "APPLE_API_KEY=private_keys/AuthKeys_$APPLE_API_KEY_ID.p8" >> "$GITHUB_ENV"
# echo "CSC_LINK=private_keys/distribution.p12" >> "$GITHUB_ENV"
openssl base64 -d <<< "$API_KEY_P8" -out "private_keys/AuthKeys_$APPLE_API_KEY_ID.p8"
# openssl base64 -d <<< "$DIST_CERT_P12" -out "private_keys/distribution.p12"
- name: macOS - Import Certs into keychain
if: ${{ matrix.platform == 'darwin' }}
uses: apple-actions/import-codesign-certs@v3
with:
p12-file-base64: ${{ env.CSC_LINK }}
p12-password: ${{ env.CSC_KEY_PASSWORD }}
- name: Set Version
run: |
node -e "const fs = require('node:fs'); const pkg = require('./package.json'); pkg.version = '${{ env.PKG_VERSION }}'; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));"
- name: Build package
run: |
echo "Installing dependencies..."
npm ci
echo "Build package..."
npx quasar build -m electron -T ${{ matrix.platform }} -P always
- name: Windows - Remove universal installers
if: ${{ matrix.platform == 'win32' }}
run: |
Remove-Item dist/electron/Packaged/ietf-draftforge-win-${{ env.PKG_VERSION }}.exe
- name: Windows - Upload Build Artifact
if: ${{ matrix.platform == 'win32' }}
id: artifactupload
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-build
path: "dist/electron/Packaged/*.exe"
- id: signpath
name: Windows - Sign Executables
if: ${{ matrix.platform == 'win32' }}
uses: signpath/github-action-submit-signing-request@v1
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: '${{ secrets.SIGNPATH_ORG_ID }}'
project-slug: 'editor'
signing-policy-slug: 'release-signing'
github-artifact-id: '${{ steps.artifactupload.outputs.artifact-id }}'
wait-for-completion: true
output-artifact-directory: signed-build
- name: Windows - Install yq
if: ${{ matrix.platform == 'win32' }}
run: |
choco install yq
- name: Windows - Recalculate exec signatures for latest.yml
if: ${{ matrix.platform == 'win32' }}
run: |
$appVersion = yq '.version' dist/electron/Packaged/latest.yml
$appX64Hash = Get-FileHash "signed-build/ietf-draftforge-win-x64-$appVersion.exe" -Algorithm SHA512
$appX64HashBytes = [byte[]] -split ($appX64Hash.Hash -replace '..', '0x$& ')
$appX64HashB64 = [System.Convert]::ToBase64String($appX64HashBytes)
$appArm64Hash = Get-FileHash "signed-build/ietf-draftforge-win-arm64-$appVersion.exe" -Algorithm SHA512
$appArm64HashBytes = [byte[]] -split ($appArm64Hash.Hash -replace '..', '0x$& ')
$appArm64HashB64 = [System.Convert]::ToBase64String($appArm64HashBytes)
$appX64Size = (Get-Item "signed-build/ietf-draftforge-win-x64-$appVersion.exe").Length
$appArm64Size = (Get-Item "signed-build/ietf-draftforge-win-arm64-$appVersion.exe").Length
yq -i 'del(.files.[0]) | del(.path) | del(.sha512)' dist/electron/Packaged/latest.yml
yq -i ".files.[0].sha512 = `"$appX64HashB64`" | .files.[0].size = $appX64Size | .files.[1].sha512 = `"$appArm64HashB64`" | .files.[1].size = $appArm64Size" dist/electron/Packaged/latest.yml
- name: Windows - Add Signed Packages to Release
if: ${{ matrix.platform == 'win32' }}
uses: ncipollo/[email protected]
with:
prerelease: true
updateOnlyUnreleased: true
allowUpdates: true
omitBody: true
tag: ${{ env.PKG_VERSION }}
name: ${{ env.PKG_VERSION }}
artifacts: "signed-build/*.exe,dist/electron/Packaged/latest.yml"
token: ${{ secrets.GITHUB_TOKEN }}
- name: macOS/Linux - Add Packages to Release
if: ${{ matrix.platform != 'win32' }}
uses: ncipollo/[email protected]
with:
prerelease: true
updateOnlyUnreleased: true
allowUpdates: true
omitBody: true
tag: ${{ env.PKG_VERSION }}
name: ${{ env.PKG_VERSION }}
artifacts: "dist/electron/Packaged/*.+(dmg|zip|deb|rpm|tar.gz),dist/electron/Packaged/latest*.yml"
token: ${{ secrets.GITHUB_TOKEN }}
- name: macOS - Purge signing certs
if: ${{ matrix.platform == 'darwin' && always() }}
run: |
rm -rf private_keys
# -----------------------------------------------------------------
# RELEASE
# -----------------------------------------------------------------
release:
name: Publish Release
needs: [prepare, build-electron]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
env:
PKG_VERSION: ${{needs.prepare.outputs.pkg_version}}
steps:
- name: Finalize Release
uses: ncipollo/[email protected]
with:
allowUpdates: true
makeLatest: true
prerelease: false
omitBody: true
draft: false
tag: ${{ env.PKG_VERSION }}
name: ${{ env.PKG_VERSION }}
token: ${{ secrets.GITHUB_TOKEN }}