Skip to content

Commit b7627c9

Browse files
author
LouisDing
committed
Publish releases with GitHub CLI
1 parent c3d6d64 commit b7627c9

2 files changed

Lines changed: 51 additions & 13 deletions

File tree

.github/workflows/cd.yml

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,52 @@ jobs:
186186
187187
# ── 10. 建立 public release repo 的 GitHub Release 並上傳安裝程式與雜湊檔 ─
188188
- name: Create public GitHub Release
189-
uses: softprops/action-gh-release@v2
190-
with:
191-
repository: ${{ env.RELEASE_REPOSITORY }}
192-
tag_name: ${{ steps.version.outputs.RELEASE_TAG }}
193-
name: "YTDownloader ${{ steps.version.outputs.VERSION }}"
194-
body_path: RELEASE_NOTES.md
195-
files: |
196-
installer/Output/YTDownloader_Setup_v${{ steps.version.outputs.VERSION }}.exe
197-
installer/Output/SHA256SUMS.txt
198-
draft: false
199-
prerelease: false
200-
token: ${{ secrets.RELEASE_REPO_TOKEN }}
189+
shell: pwsh
190+
env:
191+
GH_TOKEN: ${{ secrets.RELEASE_REPO_TOKEN }}
192+
run: |
193+
$tag = "${{ steps.version.outputs.RELEASE_TAG }}"
194+
$version = "${{ steps.version.outputs.VERSION }}"
195+
$installer = "installer/Output/YTDownloader_Setup_v$version.exe"
196+
$checksums = "installer/Output/SHA256SUMS.txt"
197+
198+
if (-not (Test-Path -LiteralPath $installer)) {
199+
Write-Error "Installer not found: $installer"
200+
exit 1
201+
}
202+
203+
if (-not (Test-Path -LiteralPath $checksums)) {
204+
Write-Error "Checksum file not found: $checksums"
205+
exit 1
206+
}
207+
208+
gh release view $tag --repo $env:RELEASE_REPOSITORY *> $null
209+
if ($LASTEXITCODE -eq 0) {
210+
Write-Host "Release $tag already exists in $env:RELEASE_REPOSITORY. Updating notes and assets."
211+
gh release edit $tag `
212+
--repo $env:RELEASE_REPOSITORY `
213+
--title "YTDownloader $version" `
214+
--notes-file RELEASE_NOTES.md `
215+
--latest
216+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
217+
218+
gh release upload $tag `
219+
--repo $env:RELEASE_REPOSITORY `
220+
--clobber `
221+
$installer `
222+
$checksums
223+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
224+
} else {
225+
Write-Host "Creating release $tag in $env:RELEASE_REPOSITORY."
226+
gh release create $tag `
227+
$installer `
228+
$checksums `
229+
--repo $env:RELEASE_REPOSITORY `
230+
--title "YTDownloader $version" `
231+
--notes-file RELEASE_NOTES.md `
232+
--latest
233+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
234+
}
235+
236+
gh release view $tag --repo $env:RELEASE_REPOSITORY --json url,tagName,name,isDraft,isPrerelease
237+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

docs/PUBLIC_RELEASE_REPO.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ git push origin Release-1.0.0
8383
```
8484

8585
3. The private repository workflow builds the installer.
86-
4. The workflow publishes release assets to the public release repository.
86+
4. The workflow publishes release assets to the public release repository with GitHub CLI.
87+
5. The workflow verifies the release exists in the public release repository before finishing.
8788

8889
## Public Release Repo README Template
8990

0 commit comments

Comments
 (0)