|
| 1 | +name: Submit Packages |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [published] |
| 5 | + |
| 6 | +env: |
| 7 | + CODER_VERSION: "${{ github.event.release.tag_name }}" |
| 8 | + |
| 9 | +jobs: |
| 10 | + winget: |
| 11 | + runs-on: windows-latest |
| 12 | + steps: |
| 13 | + - name: Install wingetcreate |
| 14 | + run: | |
| 15 | + Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe |
| 16 | +
|
| 17 | + # the package version is the same as the release tag without the leading |
| 18 | + # "v", and with a trailing ".0" (e.g. "v1.2.3" -> "1.2.3.0") |
| 19 | + - name: Calculate package version |
| 20 | + id: version |
| 21 | + run: | |
| 22 | + $version = $env:CODER_VERSION -replace "^v", "" |
| 23 | + $version += ".0" |
| 24 | + echo "::set-output name=version::$version" |
| 25 | +
|
| 26 | + - name: Submit updated manifest to winget-pkgs |
| 27 | + run: | |
| 28 | + $release_assets = gh release view --repo coder/coder "$env:CODER_VERSION" --json assets | ` |
| 29 | + ConvertFrom-Json |
| 30 | +
|
| 31 | + $installer_url = $release_assets.assets | ` |
| 32 | + Where-Object name -Match ".*_windows_amd64_installer.exe$" | ` |
| 33 | + Select -ExpandProperty url |
| 34 | +
|
| 35 | + echo "Installer URL: $installer_url" |
| 36 | +
|
| 37 | + # version should be extracted from the installer |
| 38 | + wingetcreate update Coder.Coder ` |
| 39 | + --submit ` |
| 40 | + --version "${{ steps.version.outputs.version }}" ` |
| 41 | + --urls "$installer_url" ` |
| 42 | + --token "${{ secrets.CDRCI_GITHUB_TOKEN }}" |
| 43 | +
|
| 44 | + - name: Comment on PR |
| 45 | + run: | |
| 46 | + # find the PR that wingetcreate just made |
| 47 | + $pr_list = gh pr list --repo microsoft/winget-pkgs --search "author:cdrci Coder.Coder version ${{ steps.version.outputs.version }}" --limit 1 --json number | ` |
| 48 | + ConvertFrom-Json` |
| 49 | + $pr_number = $pr_list[0].number |
| 50 | +
|
| 51 | + gh pr comment --repo microsoft/winget-pkgs "$pr_number" --body "🤖 cc: @deansheather" |
0 commit comments