|
36 | 36 | env:
|
37 | 37 | # Necessary for Docker manifest
|
38 | 38 | DOCKER_CLI_EXPERIMENTAL: "enabled"
|
| 39 | + outputs: |
| 40 | + version: ${{ steps.version.outputs.version }} |
39 | 41 | steps:
|
40 | 42 | - uses: actions/checkout@v3
|
41 | 43 | with:
|
|
49 | 51 | - name: Fetch git tags
|
50 | 52 | run: git fetch --tags --force
|
51 | 53 |
|
| 54 | + - name: Print version |
| 55 | + id: version |
| 56 | + run: | |
| 57 | + set -euo pipefail |
| 58 | + version="$(./scripts/version.sh)" |
| 59 | + echo "version=$version" >> $GITHUB_OUTPUT |
| 60 | + # Speed up future version.sh calls. |
| 61 | + echo "CODER_FORCE_VERSION=$version" >> $GITHUB_ENV |
| 62 | + echo "$version" |
| 63 | +
|
52 | 64 | - name: Create release notes
|
53 | 65 | env:
|
54 | 66 | # We always have to set this since there might be commits on
|
@@ -238,3 +250,80 @@ jobs:
|
238 | 250 | ./build/*.deb
|
239 | 251 | ./build/*.rpm
|
240 | 252 | retention-days: 7
|
| 253 | + |
| 254 | + publish-winget: |
| 255 | + runs-on: windows-latest |
| 256 | + needs: release |
| 257 | + steps: |
| 258 | + - uses: actions/checkout@v3 |
| 259 | + with: |
| 260 | + fetch-depth: 0 |
| 261 | + |
| 262 | + # If the event that triggered the build was an annotated tag (which our |
| 263 | + # tags are supposed to be), actions/checkout has a bug where the tag in |
| 264 | + # question is only a lightweight tag and not a full annotated tag. This |
| 265 | + # command seems to fix it. |
| 266 | + # https://github.com/actions/checkout/issues/290 |
| 267 | + - name: Fetch git tags |
| 268 | + run: git fetch --tags --force |
| 269 | + |
| 270 | + - name: Install wingetcreate |
| 271 | + run: | |
| 272 | + Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe |
| 273 | +
|
| 274 | + - name: Submit updated manifest to winget-pkgs |
| 275 | + run: | |
| 276 | + # The package version is the same as the tag minus the leading "v". |
| 277 | + # The version in this output already has the leading "v" removed but |
| 278 | + # we do it again to be safe. |
| 279 | + $version = "${{ needs.release.outputs.version }}".Trim('v') |
| 280 | +
|
| 281 | + $release_assets = gh release view --repo coder/coder "v${version}" --json assets | ` |
| 282 | + ConvertFrom-Json |
| 283 | + # Get the installer URL from the release assets. |
| 284 | + $installer_url = $release_assets.assets | ` |
| 285 | + Where-Object name -Match ".*_windows_amd64_installer.exe$" | ` |
| 286 | + Select -ExpandProperty url |
| 287 | +
|
| 288 | + echo "Installer URL: ${installer_url}" |
| 289 | + echo "Package version: ${version}" |
| 290 | +
|
| 291 | + # Bail if dry-run. |
| 292 | + if ($env:CODER_DRY_RUN -match "t") { |
| 293 | + echo "Skipping submission due to dry-run." |
| 294 | + exit 0 |
| 295 | + } |
| 296 | +
|
| 297 | + # The URL "|X64" suffix forces the architecture as it cannot be |
| 298 | + # sniffed properly from the URL. wingetcreate checks both the URL and |
| 299 | + # binary magic bytes for the architecture and they need to both match, |
| 300 | + # but they only check for `x64`, `win64` and `_64` in the URL. Our URL |
| 301 | + # contains `amd64` which doesn't match sadly. |
| 302 | + # |
| 303 | + # wingetcreate will still do the binary magic bytes check, so if we |
| 304 | + # accidentally change the architecture of the installer, it will fail |
| 305 | + # submission. |
| 306 | + .\wingetcreate.exe update Coder.Coder ` |
| 307 | + --submit ` |
| 308 | + --version "${version}" ` |
| 309 | + --urls "${installer_url}|X64" ` |
| 310 | + --token "${{ secrets.CDRCI_GITHUB_TOKEN }}" |
| 311 | +
|
| 312 | + env: |
| 313 | + # For gh CLI: |
| 314 | + GH_TOKEN: ${{ github.token }} |
| 315 | + |
| 316 | + - name: Comment on PR |
| 317 | + run: | |
| 318 | + # Find the PR that wingetcreate just made. |
| 319 | + $version = "${{ needs.release.outputs.version }}".Trim('v') |
| 320 | + $pr_list = gh pr list --repo microsoft/winget-pkgs --search "author:cdrci Coder.Coder version ${version}" --limit 1 --json number | ` |
| 321 | + ConvertFrom-Json` |
| 322 | + $pr_number = $pr_list[0].number |
| 323 | +
|
| 324 | + gh pr comment --repo microsoft/winget-pkgs "${pr_number}" --body "🤖 cc: @deansheather @matifali" |
| 325 | +
|
| 326 | + env: |
| 327 | + # For gh CLI. We need a real token since we're commenting on a PR in a |
| 328 | + # different repo. |
| 329 | + GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }} |
0 commit comments