Skip to content

Commit 30c59bb

Browse files
authored
Changes to release.yml to get winget upload working (#165)
- We're using a different GH auth token now that has enough credentials to do a `gh repo sync` - Add `GitHubReleaseAlreadyExists` parameter to test out pipeline stages on a build that's already been released to GH - Download and extract gh.exe, winget isn't available in the pipeline
1 parent 0f58f6e commit 30c59bb

File tree

1 file changed

+60
-47
lines changed

1 file changed

+60
-47
lines changed

.pipelines/release.yml

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ resources:
1313

1414
parameters:
1515
- name: DoEsrp
16+
displayName: Sign the binaries and package (DoEsrp)
1617
type: boolean
1718
default: true
1819
- name: signingIdentity
@@ -25,6 +26,10 @@ parameters:
2526
authCertName: $(SigningAuthCertName)
2627
signCertName: $(SigningSignCertName)
2728
signTTSCertName: $(SigningSignTTSCertName)
29+
- name: GitHubReleaseAlreadyExists
30+
displayName: GitHub Release already exists, skip uploading GitHub release (GitHubReleaseAlreadyExists)
31+
type: boolean
32+
default: false
2833

2934
extends:
3035
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
@@ -128,51 +133,52 @@ extends:
128133
includeRootFolder: false
129134
archiveFile: $(Pipeline.Workspace)/winappcli-$(version)-arm64.zip
130135

131-
- task: GitHubRelease@1
132-
displayName: "Create GitHub Release"
133-
inputs:
134-
gitHubConnection: 'github-service-connection'
135-
repositoryName: 'microsoft/winappcli'
136-
action: 'create'
137-
target: '$(Build.SourceVersion)'
138-
tagSource: 'userSpecifiedTag'
139-
tag: 'v$(version)'
140-
title: 'Release v$(version)'
141-
isPreRelease: true
142-
assets: |
143-
$(Pipeline.Workspace)/winappcli-*.zip
144-
$(Pipeline.Workspace)/msix-packages/*.msix
145-
$(Pipeline.Workspace)/npm-package/*.tgz
146-
assetUploadMode: 'delete'
147-
addChangeLog: false
148-
releaseNotesSource: 'inline'
149-
releaseNotesInline: |
150-
🚀 **Automated Release Build**
136+
- ${{ if ne(parameters.GitHubReleaseAlreadyExists, 'true') }}:
137+
- task: GitHubRelease@1
138+
displayName: "Create GitHub Release"
139+
inputs:
140+
gitHubConnection: 'github-service-connection'
141+
repositoryName: 'microsoft/winappcli'
142+
action: 'create'
143+
target: '$(Build.SourceVersion)'
144+
tagSource: 'userSpecifiedTag'
145+
tag: 'v$(version)'
146+
title: 'Release v$(version)'
147+
isPreRelease: true
148+
assets: |
149+
$(Pipeline.Workspace)/winappcli-*.zip
150+
$(Pipeline.Workspace)/msix-packages/*.msix
151+
$(Pipeline.Workspace)/npm-package/*.tgz
152+
assetUploadMode: 'delete'
153+
addChangeLog: false
154+
releaseNotesSource: 'inline'
155+
releaseNotesInline: |
156+
🚀 **Automated Release Build**
151157
152-
Version: `$(version)`
153-
Commit: `$(Build.SourceVersion)`
158+
Version: `$(version)`
159+
Commit: `$(Build.SourceVersion)`
154160
155-
## Installation Options
161+
## Installation Options
156162
157-
### 📦 MSIX Installer (Recommended)
158-
1. Download `winappcli_$(version).0_x64.msix` for x64 or `winappcli_$(version).0_arm64.msix` for ARM64
159-
2. Double-click to install
160-
3. Automatically added to PATH
163+
### 📦 MSIX Installer (Recommended)
164+
1. Download `winappcli_$(version).0_x64.msix` for x64 or `winappcli_$(version).0_arm64.msix` for ARM64
165+
2. Double-click to install
166+
3. Automatically added to PATH
161167
162-
### 📦 Standalone CLI Binaries
163-
1. Download `winappcli-$(version)-x64.zip` for x64 or `winappcli-$(version)-arm64.zip` for ARM64
164-
2. Extract to your desired location
165-
3. Add to PATH or run directly: `winapp.exe`
168+
### 📦 Standalone CLI Binaries
169+
1. Download `winappcli-$(version)-x64.zip` for x64 or `winappcli-$(version)-arm64.zip` for ARM64
170+
2. Extract to your desired location
171+
3. Add to PATH or run directly: `winapp.exe`
166172
167-
### 📚 NPM Package (for Electron or NodeJS)
168-
```bash
169-
npm install microsoft-winappcli-$(version).tgz
170-
```
173+
### 📚 NPM Package (for Electron or NodeJS)
174+
```bash
175+
npm install microsoft-winappcli-$(version).tgz
176+
```
171177
172-
## What's Included
173-
- ✅ MSIX installer packages (x64 and ARM64)
174-
- ✅ Standalone CLI binaries (x64 and ARM64)
175-
- ✅ NPM package for NodeJS/Electron integration
178+
## What's Included
179+
- ✅ MSIX installer packages (x64 and ARM64)
180+
- ✅ Standalone CLI binaries (x64 and ARM64)
181+
- ✅ NPM package for NodeJS/Electron integration
176182
177183
- ${{ if eq(parameters.DoEsrp, 'true') }}:
178184
- stage: Release_Npm
@@ -194,6 +200,12 @@ extends:
194200
artifactName: npm-package
195201
targetPath: $(Pipeline.Workspace)/npm-package
196202
steps:
203+
- task: PowerShell@2
204+
displayName: "Echo debug info"
205+
inputs:
206+
targetType: 'inline'
207+
script: |
208+
Write-Host "SigningServiceName: ${{ parameters.signingIdentity.serviceName }}"
197209
- task: EsrpRelease@10
198210
condition: always()
199211
inputs:
@@ -234,10 +246,11 @@ extends:
234246
displayName: "Publish to WinGet"
235247
env:
236248
# PAT lasts 90 days, regenerate as needed and re-run if it failes due to authentication
237-
WINGET_CREATE_GITHUB_TOKEN: $(GITHUB_TOKEN)
238-
GH_TOKEN: $(GITHUB_TOKEN)
249+
WINGET_CREATE_GITHUB_TOKEN: $(GITHUB_TOKEN_2)
250+
GH_TOKEN: $(GITHUB_TOKEN_2)
239251
inputs:
240252
targetType: 'inline'
253+
errorActionPreference: 'stop'
241254
script: |
242255
# Download and install C++ Runtime framework package
243256
Write-Host "Installing VCLibs dependency..."
@@ -246,12 +259,12 @@ extends:
246259
Add-AppxPackage $vcLibsFile
247260
248261
# Install gh
262+
# TODO: Change this to get the latest version of gh
249263
Write-Host "Installing gh..."
250-
winget install --id GitHub.cli --source winget --silent --accept-source-agreements
251-
if ($LASTEXITCODE -ne 0) {
252-
Write-Host "winget returned exit code: $LASTEXITCODE"
253-
Write-Host "Continuing in case gh is already installed..."
254-
}
264+
$tempDir = "$(Agent.TempDirectory)"
265+
Write-Host "TempDir: $tempDir"
266+
Invoke-WebRequest -Uri "https://github.com/cli/cli/releases/download/v2.83.1/gh_2.83.1_windows_amd64.zip" -OutFile "$tempdir\gh.zip"
267+
Expand-Archive "$tempdir\gh.zip" -DestinationPath "$tempDir\gh"
255268
256269
# Download and install wingetcreate
257270
Write-Host "Installing wingetcreate..."
@@ -264,7 +277,7 @@ extends:
264277
# We need to keep this fork up-to-date, otherwise the wingetcreate command will fail.
265278
# See: https://github.com/microsoft/winget-create/issues/502
266279
Write-Host "Syncing winget-pkgs fork..."
267-
& "$env:ProgramFiles\GitHub CLI\gh.exe" repo sync $(WingetPkgsFork) -b master
280+
& "$tempDir\gh\bin\gh.exe" repo sync $(WingetPkgsFork) -b master
268281
if ($LASTEXITCODE -ne 0) {
269282
Write-Error "Failed to sync winget-pkgs fork. Exit code: $LASTEXITCODE"
270283
exit $LASTEXITCODE

0 commit comments

Comments
 (0)