Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 990be63

Browse files
feat: create winget package workflow (#4761)
Co-authored-by: Dean Sheather <[email protected]>
1 parent 1b6d0c3 commit 990be63

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

.github/workflows/packages.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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"

scripts/build_windows_installer.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ fi
6767
# Remove the "v" prefix and ensure the version is in the format X.X.X.X for
6868
# makensis.
6969
nsis_version="${version//-*/}"
70-
nsis_version+=".$(date -u +%Y%m%d%H%M)"
70+
# Each component of a version must be a 16 bit integer, so we can't store any
71+
# useful information like build date or commit SHA in the 4th component.
72+
nsis_version+=".0"
7173

7274
# Check dependencies
7375
dependencies makensis

scripts/win-installer/installer.nsi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# adapted to Coder's needs:
33
# https://www.conjur.org/blog/building-a-windows-installer-from-a-linux-ci-pipeline/
44

5+
# Since we only build an AMD64 installer for now, ensure that the generated
6+
# installer matches so wingetcreate can sniff the architecture properly.
7+
CPU amd64
58
Unicode true
69

710
!define APP_NAME "Coder"

0 commit comments

Comments
 (0)