@@ -3,6 +3,8 @@ name: Windows Installer
33on :
44 workflow_dispatch :
55 push :
6+ branches :
7+ - main
68 tags :
79 - " v*"
810
6769 path : cbm_defaults
6870 token : ${{ secrets.CROSS_REPO_READ_TOKEN }}
6971
72+ - name : Set installer metadata
73+ id : meta
74+ shell : pwsh
75+ run : |
76+ $sha = $env:GITHUB_SHA.Substring(0, 7)
77+ if ($env:GITHUB_REF -like 'refs/tags/v*') {
78+ $version = $env:GITHUB_REF_NAME.Substring(1)
79+ $channel = "release"
80+ } elseif ($env:GITHUB_REF -eq 'refs/heads/main') {
81+ $version = "0.0.$($env:GITHUB_RUN_NUMBER)"
82+ $channel = "continuous"
83+ } else {
84+ $version = "0.0.$($env:GITHUB_RUN_NUMBER)"
85+ $channel = "manual"
86+ }
87+
88+ "INSTALLER_VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
89+ "INSTALLER_CHANNEL=$channel" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
90+ "INSTALLER_SHA=$sha" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
91+
92+ "installer_version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
93+ "installer_channel=$channel" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
94+
7095 - name : Setup Python 3.10
7196 uses : actions/setup-python@v5
7297 with :
@@ -99,17 +124,62 @@ jobs:
99124 shell : pwsh
100125 run : |
101126 & "C:\\Program Files (x86)\\Inno Setup 6\\ISCC.exe" `
127+ "/DMyAppVersion=$env:INSTALLER_VERSION" `
102128 "$env:GITHUB_WORKSPACE\\gcbm_view\\installer\\gcbm_view_installer.iss"
103129
104130 - name : Upload installer artifact
105131 uses : actions/upload-artifact@v4
106132 with :
107- name : gcbm-view-installer
133+ name : gcbm-view-installer-${{ env.INSTALLER_VERSION }}-${{ env.INSTALLER_SHA }}
108134 path : gcbm_view/installer/output/*.exe
109135 if-no-files-found : error
110136
111- - name : Publish GitHub release asset
137+ - name : Publish versioned release asset
112138 if : startsWith(github.ref, 'refs/tags/')
113139 uses : softprops/action-gh-release@v2
114140 with :
141+ name : GCBM View v${{ env.INSTALLER_VERSION }}
142+ generate_release_notes : true
143+ files : gcbm_view/installer/output/*.exe
144+ overwrite_files : true
145+
146+ - name : Cleanup continuous release assets
147+ if : github.ref == 'refs/heads/main'
148+ uses : actions/github-script@v7
149+ with :
150+ script : |
151+ const tag = "continuous";
152+ try {
153+ const rel = await github.rest.repos.getReleaseByTag({
154+ owner: context.repo.owner,
155+ repo: context.repo.repo,
156+ tag
157+ });
158+ for (const asset of rel.data.assets) {
159+ await github.rest.repos.deleteReleaseAsset({
160+ owner: context.repo.owner,
161+ repo: context.repo.repo,
162+ asset_id: asset.id
163+ });
164+ }
165+ core.info(`Removed ${rel.data.assets.length} old asset(s) from ${tag}.`);
166+ } catch (error) {
167+ core.info(`No prior ${tag} release to clean, continuing.`);
168+ }
169+
170+ - name : Publish continuous release asset
171+ if : github.ref == 'refs/heads/main'
172+ uses : softprops/action-gh-release@v2
173+ with :
174+ tag_name : continuous
175+ name : Continuous Installer (main)
176+ body : |
177+ Auto-updated installer from `main`.
178+ - Build: `${{ github.run_number }}`
179+ - Commit: `${{ github.sha }}`
180+ - Installer version: `${{ env.INSTALLER_VERSION }}`
181+ prerelease : true
182+ make_latest : false
183+ target_commitish : ${{ github.sha }}
115184 files : gcbm_view/installer/output/*.exe
185+ overwrite_files : true
0 commit comments