-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (132 loc) · 5.04 KB
/
release.yml
File metadata and controls
158 lines (132 loc) · 5.04 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
build-and-release:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: "pip"
- name: Read app version
id: version
shell: pwsh
run: |
$version = python -c "from modules.version import __version__; print(__version__)"
if (-not $version) {
throw "Could not read version from modules/version.py"
}
"app_version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
"release_tag=v$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
- name: Validate pushed tag matches app version
shell: pwsh
run: |
if ("${{ github.ref_name }}" -ne "${{ steps.version.outputs.release_tag }}") {
throw "Tag ${{ github.ref_name }} does not match app version ${{ steps.version.outputs.app_version }}"
}
- name: Install Python dependencies
shell: pwsh
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt pyinstaller pytest
- name: Install Inno Setup
shell: pwsh
run: choco install innosetup --no-progress -y
- name: Lint
shell: pwsh
run: |
python -m pip install ruff
ruff check .
- name: Run tests
shell: pwsh
run: python -m pytest -q
- name: Validate release metadata
shell: pwsh
run: python tools/dev/release_bump.py --validate
- name: Build executable
shell: cmd
run: tools\build\build_exe.bat --nopause
- name: Smoke test EXE
shell: pwsh
run: |
$p = Start-Process -FilePath "dist\KeyQuest\KeyQuest.exe" -ArgumentList "--version" -Wait -PassThru -NoNewWindow
if ($p.ExitCode -ne 0) { throw "EXE smoke test failed with exit code $($p.ExitCode)" }
- name: Build portable zip
shell: cmd
run: tools\build\build_portable_zip.bat --nopause
- name: Build installer
shell: cmd
run: tools\build\build_installer.bat --nopause
- name: Verify release outputs
shell: pwsh
run: |
if (-not (Test-Path "dist\KeyQuest-win64.zip")) {
throw "dist\\KeyQuest-win64.zip was not created"
}
if (-not (Test-Path "dist\installer\KeyQuestSetup.exe")) {
throw "dist\\installer\\KeyQuestSetup.exe was not created"
}
- name: Generate SHA-256 sidecars
id: hashes
shell: pwsh
run: |
$zipHash = (Get-FileHash "dist\KeyQuest-win64.zip" -Algorithm SHA256).Hash.ToLower()
"$zipHash KeyQuest-win64.zip" | Set-Content -Encoding utf8 "dist\KeyQuest-win64.zip.sha256"
$exeHash = (Get-FileHash "dist\installer\KeyQuestSetup.exe" -Algorithm SHA256).Hash.ToLower()
"$exeHash KeyQuestSetup.exe" | Set-Content -Encoding utf8 "dist\installer\KeyQuestSetup.exe.sha256"
"zip_hash=$zipHash" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
"exe_hash=$exeHash" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
Write-Host "ZIP : $zipHash"
Write-Host "Setup: $exeHash"
- name: Publish GitHub release
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$pagesUrl = "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/"
$releaseIntro = @"
User guide: $pagesUrl
Changelog: ${pagesUrl}changelog.html
SHA-256:
KeyQuest-win64.zip: ${{ steps.hashes.outputs.zip_hash }}
KeyQuestSetup.exe: ${{ steps.hashes.outputs.exe_hash }}
"@
gh release create "${{ steps.version.outputs.release_tag }}" `
"dist\KeyQuest-win64.zip#KeyQuest-win64.zip" `
"dist\KeyQuest-win64.zip.sha256#KeyQuest-win64.zip.sha256" `
"dist\installer\KeyQuestSetup.exe#KeyQuestSetup.exe" `
"dist\installer\KeyQuestSetup.exe.sha256#KeyQuestSetup.exe.sha256" `
--title "KeyQuest ${{ steps.version.outputs.app_version }}" `
--notes "$releaseIntro" `
--generate-notes `
--latest
post-release-smoke-test:
needs: build-and-release
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: "pip"
- name: Install dependencies
shell: pwsh
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Run update smoke test
shell: pwsh
run: python tests/update_smoke_test.py