Skip to content

Commit e51bee2

Browse files
committed
Add release channels and dynamic installer versioning
1 parent b009705 commit e51bee2

2 files changed

Lines changed: 64 additions & 7 deletions

File tree

.github/workflows/windows-installer.yml

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,29 @@ jobs:
6969
path: cbm_defaults
7070
token: ${{ secrets.CROSS_REPO_READ_TOKEN }}
7171

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+
7295
- name: Setup Python 3.10
7396
uses: actions/setup-python@v5
7497
with:
@@ -101,28 +124,60 @@ jobs:
101124
shell: pwsh
102125
run: |
103126
& "C:\\Program Files (x86)\\Inno Setup 6\\ISCC.exe" `
127+
"/DMyAppVersion=$env:INSTALLER_VERSION" `
104128
"$env:GITHUB_WORKSPACE\\gcbm_view\\installer\\gcbm_view_installer.iss"
105129
106130
- name: Upload installer artifact
107131
uses: actions/upload-artifact@v4
108132
with:
109-
name: gcbm-view-installer
133+
name: gcbm-view-installer-${{ env.INSTALLER_VERSION }}-${{ env.INSTALLER_SHA }}
110134
path: gcbm_view/installer/output/*.exe
111135
if-no-files-found: error
112136

113-
- name: Publish GitHub release asset
137+
- name: Publish versioned release asset
114138
if: startsWith(github.ref, 'refs/tags/')
115139
uses: softprops/action-gh-release@v2
116140
with:
141+
name: GCBM View v${{ env.INSTALLER_VERSION }}
142+
generate_release_notes: true
117143
files: gcbm_view/installer/output/*.exe
118144
overwrite_files: true
119145

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+
120170
- name: Publish continuous release asset
121171
if: github.ref == 'refs/heads/main'
122172
uses: softprops/action-gh-release@v2
123173
with:
124174
tag_name: continuous
125175
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 }}`
126181
prerelease: true
127182
make_latest: false
128183
target_commitish: ${{ github.sha }}

installer/gcbm_view_installer.iss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
; GCBM View Installer Script
22
; Built with Inno Setup (https://jrsoftware.org/isinfo.php)
33

4-
#define MyAppName "GCBM View"
5-
#define MyAppVersion "0.5.9"
6-
#define MyAppPublisher "Moja Global"
7-
#define MyAppURL "https://moja.global"
8-
#define MyAppExeName "GCBMView.bat"
4+
#define MyAppName "GCBM View"
5+
#ifndef MyAppVersion
6+
#define MyAppVersion "0.5.9"
7+
#endif
8+
#define MyAppPublisher "Moja Global"
9+
#define MyAppURL "https://moja.global"
10+
#define MyAppExeName "GCBMView.bat"
911

1012
[Setup]
1113
AppId={{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}

0 commit comments

Comments
 (0)