-
-
Notifications
You must be signed in to change notification settings - Fork 160
307 lines (278 loc) · 10.5 KB
/
windows-dev.yaml
File metadata and controls
307 lines (278 loc) · 10.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
name: Build Dev Release
on:
workflow_dispatch:
permissions:
contents: read
env:
PYTHON_VERSION: '3.14'
jobs:
build:
permissions:
contents: write
strategy:
matrix:
include:
- arch: x64
runner: windows-latest
python_arch: x64
artifact_suffix: x64
unsigned_exe_name: unsigned-exes-x64
unsigned_msi_name: unsigned-msi-x64
- arch: arm64
runner: windows-11-arm
python_arch: arm64
artifact_suffix: aarch64
unsigned_exe_name: unsigned-exes-arm64
unsigned_msi_name: unsigned-msi-arm64
runs-on: ${{ matrix.runner }}
name: Build (${{ matrix.arch }})
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: ${{ matrix.python_arch }}
- name: Create virtual environment
run: |
python -m venv venv
shell: pwsh
- name: Get App Info
id: get_info
run: |
.\venv\Scripts\Activate
$currentDateTime = Get-Date -Format "yyyy-MM-dd HH:mm:ss UTC"
echo "BUILD_DATETIME=$currentDateTime" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
$commitHash = git rev-parse --short HEAD
echo "COMMIT_HASH=$commitHash" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# Also expose as step outputs for use in later expression fields
echo "BUILD_DATETIME=$currentDateTime" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
echo "COMMIT_HASH=$commitHash" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
shell: pwsh
- name: Update Release Channel
run: |
.\venv\Scripts\Activate
$settingsPath = "src/settings.py"
$content = Get-Content $settingsPath -Raw
$replacement = 'RELEASE_CHANNEL = "dev-' + $env:COMMIT_HASH + '"'
$content = $content -replace 'RELEASE_CHANNEL = "stable"', $replacement
Set-Content -Path $settingsPath -Value $content -NoNewline
Write-Host "Updated RELEASE_CHANNEL to dev-$env:COMMIT_HASH"
shell: pwsh
- name: Install dependencies
run: |
.\venv\Scripts\Activate
python -m pip install --upgrade pip
pip install --force --no-cache .[packaging]
shell: pwsh
- name: Build EXE
run: |
.\venv\Scripts\Activate
cd src
python build.py build
shell: pwsh
- name: Upload unsigned EXE artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.unsigned_exe_name }}
path: |
src/dist/yasb.exe
src/dist/yasbc.exe
src/dist/yasb_themes.exe
- name: Get unsigned-exes artifact id
id: get_exes_artifact
uses: actions/github-script@v7
env:
ARTIFACT_NAME: ${{ matrix.unsigned_exe_name }}
with:
github-token: ${{ secrets.PAT }}
script: |
const { owner, repo } = context.repo;
const run_id = context.runId;
const expectedName = process.env.ARTIFACT_NAME;
const res = await github.rest.actions.listWorkflowRunArtifacts({ owner, repo, run_id });
const artifact = res.data.artifacts.find(a => a.name === expectedName);
if (!artifact) throw new Error(`${expectedName} artifact not found`);
return artifact.id;
- name: Submit EXE signing request
id: sign_exes
uses: signpath/github-action-submit-signing-request@v1
with:
api-token: '${{ secrets.SIGN_TOKEN }}'
organization-id: '9efb6764-d1fc-46c5-b050-5ef07bb67a8c'
project-slug: 'yasb'
signing-policy-slug: '${{ secrets.SIGN_POLICY_SLUG }}'
artifact-configuration-slug: 'signing_executable'
github-artifact-id: '${{ steps.get_exes_artifact.outputs.result }}'
wait-for-completion: 'true'
output-artifact-directory: 'src/signed'
- name: Replace unsigned EXE with signed
if: steps.sign_exes.outcome == 'success'
run: |
.\venv\Scripts\Activate
$signedDir = 'src/signed'
if (-not (Test-Path $signedDir)) {
Write-Host "Signed artifacts directory $signedDir not found. Ensure SignPath places signed files there.";
exit 1
}
# Copy signed EXEs into the distribution folder; fail if none found
$signedExes = Get-ChildItem -Path $signedDir -File -Filter '*.exe' -Recurse -ErrorAction SilentlyContinue
if ($null -eq $signedExes -or $signedExes.Count -eq 0) {
Write-Error "No signed .exe files found in $signedDir after extraction. Failing the job."
exit 1
}
Write-Host "Copying signed EXEs from $signedDir to src/dist"
foreach ($f in $signedExes) {
Copy-Item -Path $f.FullName -Destination (Join-Path 'src/dist' $f.Name) -Force
}
# Clean up signed directory after successful copy
try {
Get-ChildItem -Path $signedDir -Recurse -Force | Remove-Item -Force -Recurse
Write-Host "Cleaned up $signedDir"
} catch {
Write-Warning "Failed to clean up ${signedDir}: $($_.Exception.Message)"
}
shell: pwsh
- name: Build MSI
run: |
.\venv\Scripts\Activate
cd src
python build.py bdist_msi
shell: pwsh
- name: Upload unsigned MSI
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.unsigned_msi_name }}
path: src/dist/out/*.msi
- name: Get unsigned-msi artifact id
id: get_msi_artifact
uses: actions/github-script@v7
env:
ARTIFACT_NAME: ${{ matrix.unsigned_msi_name }}
with:
github-token: ${{ secrets.PAT }}
script: |
const { owner, repo } = context.repo;
const run_id = context.runId;
const expectedName = process.env.ARTIFACT_NAME;
const res = await github.rest.actions.listWorkflowRunArtifacts({ owner, repo, run_id });
const artifact = res.data.artifacts.find(a => a.name === expectedName);
if (!artifact) throw new Error(`${expectedName} artifact not found`);
return artifact.id;
- name: Submit MSI signing request
id: sign_msi
uses: signpath/github-action-submit-signing-request@v1
with:
api-token: '${{ secrets.SIGN_TOKEN }}'
organization-id: '9efb6764-d1fc-46c5-b050-5ef07bb67a8c'
project-slug: 'yasb'
signing-policy-slug: '${{ secrets.SIGN_POLICY_SLUG }}'
artifact-configuration-slug: 'signing_installer'
github-artifact-id: '${{ steps.get_msi_artifact.outputs.result }}'
wait-for-completion: 'true'
output-artifact-directory: 'src/signed'
- name: Replace unsigned MSI with signed
if: steps.sign_msi.outcome == 'success'
run: |
.\venv\Scripts\Activate
$signedDir = 'src/signed'
if (-not (Test-Path $signedDir)) {
Write-Host "Signed artifacts directory $signedDir not found. Ensure SignPath places signed files there.";
exit 1
}
# Copy signed MSIs into the output folder; fail if none found
$signedMsis = Get-ChildItem -Path $signedDir -File -Filter '*.msi' -Recurse -ErrorAction SilentlyContinue
if ($null -eq $signedMsis -or $signedMsis.Count -eq 0) {
Write-Error "No signed .msi files found in $signedDir after extraction. Failing the job."
exit 1
}
Write-Host "Copying signed MSIs from $signedDir to src/dist/out"
foreach ($f in $signedMsis) {
Copy-Item -Path $f.FullName -Destination (Join-Path 'src/dist/out' $f.Name) -Force
}
# Clean up signed directory after successful copy
try {
Get-ChildItem -Path $signedDir -Recurse -Force | Remove-Item -Force -Recurse
Write-Host "Cleaned up $signedDir"
} catch {
Write-Warning "Failed to clean up ${signedDir}: $($_.Exception.Message)"
}
shell: pwsh
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: yasb-dev-${{ steps.get_info.outputs.COMMIT_HASH }}-${{ matrix.artifact_suffix }}
path: |
src/dist/out/*.msi
retention-days: 10
- name: Delete Artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: |
unsigned-*
signed-*
publish_dev_release:
needs: build
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Set release metadata
id: release_info
run: |
currentDateTime=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
echo "BUILD_DATETIME=$currentDateTime" >> "$GITHUB_ENV"
commitHash=$(git rev-parse --short HEAD)
echo "COMMIT_HASH=$commitHash" >> "$GITHUB_ENV"
echo "COMMIT_HASH=$commitHash" >> "$GITHUB_OUTPUT"
- name: Generate Changelog
run: |
latestVersionTag=$(git tag --sort=-version:refname | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1 || true)
if [ -n "$latestVersionTag" ]; then
commits=$(git log "$latestVersionTag..HEAD" --pretty=format:"* %s %h" --no-merges)
else
commits=$(git log -n 20 --pretty=format:"* %s %h" --no-merges)
fi
if [ -z "$commits" ]; then
if [ -n "$latestVersionTag" ]; then
commits="* No significant changes detected since $latestVersionTag"
else
commits="* No significant changes detected"
fi
fi
printf '%s\n' "$commits" > CHANGELOG.md
- name: Download MSI artifacts
uses: actions/download-artifact@v4
with:
pattern: yasb-dev-*
path: artifacts
merge-multiple: true
- name: Generate Checksums
run: |
cd artifacts
sha256sum *.msi > checksums.txt
- name: Delete existing dev release
run: |
gh release delete dev --yes || true
git tag -d dev || true
git push origin :refs/tags/dev || true
env:
GH_TOKEN: ${{ github.token }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: YASB Pre-release (${{ steps.release_info.outputs.COMMIT_HASH }})
tag_name: dev
prerelease: true
files: |
artifacts/*.msi
artifacts/checksums.txt
body_path: CHANGELOG.md