Skip to content

Commit b8ec930

Browse files
authored
fix: use template-based winget submit for jtk releases (#89)
* fix: use template-based winget submit instead of wingetcreate update wingetcreate update fetches the published manifest from microsoft/winget-pkgs, which still has RelativeFilePath: jira-ticket-cli.exe from before the rename. The zip now contains jtk.exe, causing "Nested installer not found" errors. Switch to a template-based approach: copy local manifest templates, substitute version/checksum placeholders, and use wingetcreate submit. This bypasses the auto-detection entirely and gives full control over manifest content. Also updates installer template to use distinct checksum placeholders (CHECKSUM_AMD64_PLACEHOLDER, CHECKSUM_ARM64_PLACEHOLDER) to avoid PowerShell -replace ordering ambiguity, and updates README with correct binary names and URL patterns. * fix: update winget validation test for named checksum placeholders The test-winget CI was using [regex]::Replace with 0{64} pattern to substitute checksums one at a time. Now that the jtk installer template uses distinct named placeholders (CHECKSUM_AMD64_PLACEHOLDER, CHECKSUM_ARM64_PLACEHOLDER), update the test to match.
1 parent b602b12 commit b8ec930

4 files changed

Lines changed: 47 additions & 42 deletions

File tree

.github/workflows/release-jtk.yml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,34 @@ jobs:
117117
$tag = "jtk-v$version"
118118
gh release download $tag --pattern "checksums.txt" --dir artifacts
119119
120-
- name: Extract checksums
120+
- name: Prepare winget manifests
121121
run: |
122122
$version = "${{ needs.goreleaser.outputs.version }}"
123123
$checksums = Get-Content artifacts/checksums.txt
124124
$amd64 = ($checksums | Select-String "jtk_${version}_windows_amd64.zip").ToString().Split(" ")[0]
125125
$arm64 = ($checksums | Select-String "jtk_${version}_windows_arm64.zip").ToString().Split(" ")[0]
126-
echo "CHECKSUM_AMD64=$amd64" >> $env:GITHUB_ENV
127-
echo "CHECKSUM_ARM64=$arm64" >> $env:GITHUB_ENV
126+
127+
# Copy templates to working directory
128+
New-Item -ItemType Directory -Path manifests -Force
129+
Copy-Item tools/jtk/packaging/winget/*.yaml manifests/
130+
131+
# Replace version placeholder in all manifest files
132+
Get-ChildItem manifests/*.yaml | ForEach-Object {
133+
$content = Get-Content $_.FullName -Raw
134+
$content = $content -replace '0\.0\.0', $version
135+
Set-Content $_.FullName $content -NoNewline
136+
}
137+
138+
# Set checksums in installer manifest (uses distinct placeholders)
139+
$installer = Get-Content manifests/OpenCLICollective.jira-ticket-cli.installer.yaml -Raw
140+
$installer = $installer -replace 'CHECKSUM_AMD64_PLACEHOLDER', $amd64
141+
$installer = $installer -replace 'CHECKSUM_ARM64_PLACEHOLDER', $arm64
142+
Set-Content manifests/OpenCLICollective.jira-ticket-cli.installer.yaml $installer -NoNewline
128143
129144
- name: Install wingetcreate
130145
run: |
131146
iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
132147
133-
- name: Update and submit manifest
148+
- name: Submit manifests
134149
run: |
135-
$version = "${{ needs.goreleaser.outputs.version }}"
136-
$baseUrl = "https://github.com/open-cli-collective/atlassian-cli/releases/download/jtk-v$version"
137-
138-
./wingetcreate.exe update OpenCLICollective.jira-ticket-cli `
139-
--version $version `
140-
--urls "$baseUrl/jtk_${version}_windows_amd64.zip|x64" "$baseUrl/jtk_${version}_windows_arm64.zip|arm64" `
141-
--submit `
142-
--token ${{ secrets.WINGET_GITHUB_TOKEN }}
150+
./wingetcreate.exe submit --path manifests --token ${{ secrets.WINGET_GITHUB_TOKEN }}

.github/workflows/test-winget.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ jobs:
7979
# Installer manifest
8080
$content = Get-Content "tools/jtk/packaging/winget/OpenCLICollective.jira-ticket-cli.installer.yaml" -Raw
8181
$content = $content -replace "0\.0\.0", $testVersion
82-
$regex = [regex]"0{64}"
83-
$content = $regex.Replace($content, $testHash1, 1)
84-
$content = $regex.Replace($content, $testHash2, 1)
82+
$content = $content -replace 'CHECKSUM_AMD64_PLACEHOLDER', $testHash1
83+
$content = $content -replace 'CHECKSUM_ARM64_PLACEHOLDER', $testHash2
8584
Set-Content "$testDir/OpenCLICollective.jira-ticket-cli.installer.yaml" $content -Encoding UTF8
8685
8786
Write-Host "Validating jtk winget manifest..."

tools/jtk/packaging/winget/OpenCLICollective.jira-ticket-cli.installer.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ NestedInstallerFiles:
1010
Installers:
1111
- Architecture: x64
1212
InstallerUrl: https://github.com/open-cli-collective/atlassian-cli/releases/download/jtk-v0.0.0/jtk_0.0.0_windows_amd64.zip
13-
InstallerSha256: 0000000000000000000000000000000000000000000000000000000000000000
13+
InstallerSha256: CHECKSUM_AMD64_PLACEHOLDER
1414
- Architecture: arm64
1515
InstallerUrl: https://github.com/open-cli-collective/atlassian-cli/releases/download/jtk-v0.0.0/jtk_0.0.0_windows_arm64.zip
16-
InstallerSha256: 0000000000000000000000000000000000000000000000000000000000000000
16+
InstallerSha256: CHECKSUM_ARM64_PLACEHOLDER
1717
ManifestType: installer
1818
ManifestVersion: 1.10.0

tools/jtk/packaging/winget/README.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Winget Package for jira-ticket-cli
22

3-
This directory contains the Winget manifest templates for distributing jira-ticket-cli on Windows via `winget install OpenCLICollective.jira-ticket-cli`.
3+
This directory contains the Winget manifest templates for distributing jtk on Windows via `winget install OpenCLICollective.jira-ticket-cli`.
44

55
## Automated Publishing
66

7-
Publishing to Winget is automated via GitHub Actions. When a new release tag is pushed, the release workflow uses `wingetcreate` to submit a PR to [microsoft/winget-pkgs](https://github.com/microsoft/winget-pkgs).
7+
Publishing to Winget is automated via GitHub Actions. When a new release tag is pushed, the release workflow copies these templates, substitutes version/checksum placeholders, and uses `wingetcreate submit` to submit a PR to [microsoft/winget-pkgs](https://github.com/microsoft/winget-pkgs).
88

99
**Required secret:** `WINGET_GITHUB_TOKEN` - A GitHub PAT with `public_repo` scope, needed to create PRs on microsoft/winget-pkgs.
1010

@@ -24,17 +24,29 @@ packaging/winget/
2424

2525
Unlike Chocolatey (which hosts packages on their own feed), Winget manifests live in Microsoft's community repository [microsoft/winget-pkgs](https://github.com/microsoft/winget-pkgs). Publishing requires submitting a PR to that repo.
2626

27+
## Template Placeholders
28+
29+
The manifest templates use these placeholders that are replaced during CI:
30+
31+
| Placeholder | Replaced with |
32+
|-------------|--------------|
33+
| `0.0.0` | Release version (e.g., `0.1.18`) |
34+
| `CHECKSUM_AMD64_PLACEHOLDER` | SHA256 of the x64 zip |
35+
| `CHECKSUM_ARM64_PLACEHOLDER` | SHA256 of the arm64 zip |
36+
37+
URLs contain `0.0.0` in both the tag path and filename, so the version replacement handles them automatically.
38+
2739
## Publishing a New Version
2840

2941
### Option 1: Manual PR
3042

3143
1. **Get release info:**
32-
- Download URLs: `https://github.com/open-cli-collective/jira-ticket-cli/releases/download/v<VERSION>/jira-ticket-cli_<VERSION>_windows_amd64.zip`
44+
- Download URLs: `https://github.com/open-cli-collective/atlassian-cli/releases/download/jtk-v<VERSION>/jtk_<VERSION>_windows_amd64.zip`
3345
- SHA256 checksums from `checksums.txt` in the release
3446

3547
2. **Update manifests:**
3648
- Replace `0.0.0` with the actual version in all three YAML files
37-
- Replace placeholder checksums with real SHA256 values
49+
- Replace checksum placeholders with real SHA256 values
3850

3951
3. **Validate manifests:**
4052
```powershell
@@ -52,19 +64,14 @@ Unlike Chocolatey (which hosts packages on their own feed), Winget manifests liv
5264

5365
7. **Submit PR** to microsoft/winget-pkgs
5466

55-
### Option 2: Using wingetcreate
56-
57-
[wingetcreate](https://github.com/microsoft/winget-create) can generate manifests from URLs:
67+
### Option 2: Using wingetcreate submit
5868

5969
```powershell
6070
# Install wingetcreate
6171
winget install Microsoft.WingetCreate
6272
63-
# Create new manifest (interactive)
64-
wingetcreate new https://github.com/open-cli-collective/jira-ticket-cli/releases/download/v<VERSION>/jira-ticket-cli_<VERSION>_windows_amd64.zip
65-
66-
# Or update existing manifest
67-
wingetcreate update OpenCLICollective.jira-ticket-cli --version <VERSION> --urls <x64_url> <arm64_url>
73+
# Copy and update templates, then submit
74+
wingetcreate submit --path <manifest-dir> --token <PAT>
6875
```
6976

7077
## Manifest Schema
@@ -79,25 +86,16 @@ These manifests use schema version 1.10.0:
7986
This package uses:
8087
- `InstallerType: zip` - Our releases are zip archives
8188
- `NestedInstallerType: portable` - Contains a standalone executable
82-
- `PortableCommandAlias: jira-ticket-cli` - Command users type to invoke the tool
89+
- `PortableCommandAlias: jtk` - Command users type to invoke the tool
8390

84-
Winget extracts the zip, places `jira-ticket-cli.exe` in a managed location, and creates the command alias.
91+
Winget extracts the zip, places `jtk.exe` in a managed location, and creates the command alias.
8592

8693
## Architecture Support
8794

8895
| Architecture | Installer URL Pattern |
8996
|--------------|----------------------|
90-
| x64 | `jira-ticket-cli_<VERSION>_windows_amd64.zip` |
91-
| arm64 | `jira-ticket-cli_<VERSION>_windows_arm64.zip` |
92-
93-
## Manual Retry Workflow
94-
95-
If automated publishing fails, use the manual workflow:
96-
97-
1. Go to Actions → "Publish to Winget"
98-
2. Click "Run workflow"
99-
3. Enter the version (e.g., `0.1.0`)
100-
4. Click "Run workflow"
97+
| x64 | `jtk_<VERSION>_windows_amd64.zip` |
98+
| arm64 | `jtk_<VERSION>_windows_arm64.zip` |
10199

102100
## After Approval
103101

0 commit comments

Comments
 (0)