|
69 | 69 | path: cbm_defaults |
70 | 70 | token: ${{ secrets.CROSS_REPO_READ_TOKEN }} |
71 | 71 |
|
| 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 | +
|
72 | 95 | - name: Setup Python 3.10 |
73 | 96 | uses: actions/setup-python@v5 |
74 | 97 | with: |
@@ -101,28 +124,60 @@ jobs: |
101 | 124 | shell: pwsh |
102 | 125 | run: | |
103 | 126 | & "C:\\Program Files (x86)\\Inno Setup 6\\ISCC.exe" ` |
| 127 | + "/DMyAppVersion=$env:INSTALLER_VERSION" ` |
104 | 128 | "$env:GITHUB_WORKSPACE\\gcbm_view\\installer\\gcbm_view_installer.iss" |
105 | 129 |
|
106 | 130 | - name: Upload installer artifact |
107 | 131 | uses: actions/upload-artifact@v4 |
108 | 132 | with: |
109 | | - name: gcbm-view-installer |
| 133 | + name: gcbm-view-installer-${{ env.INSTALLER_VERSION }}-${{ env.INSTALLER_SHA }} |
110 | 134 | path: gcbm_view/installer/output/*.exe |
111 | 135 | if-no-files-found: error |
112 | 136 |
|
113 | | - - name: Publish GitHub release asset |
| 137 | + - name: Publish versioned release asset |
114 | 138 | if: startsWith(github.ref, 'refs/tags/') |
115 | 139 | uses: softprops/action-gh-release@v2 |
116 | 140 | with: |
| 141 | + name: GCBM View v${{ env.INSTALLER_VERSION }} |
| 142 | + generate_release_notes: true |
117 | 143 | files: gcbm_view/installer/output/*.exe |
118 | 144 | overwrite_files: true |
119 | 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 | +
|
120 | 170 | - name: Publish continuous release asset |
121 | 171 | if: github.ref == 'refs/heads/main' |
122 | 172 | uses: softprops/action-gh-release@v2 |
123 | 173 | with: |
124 | 174 | tag_name: continuous |
125 | 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 }}` |
126 | 181 | prerelease: true |
127 | 182 | make_latest: false |
128 | 183 | target_commitish: ${{ github.sha }} |
|
0 commit comments