ci: support rebuilding a release tag via workflow_dispatch
release.yml gains a required tag input so an existing tag can be rebuilt without re-pushing it. The tag is checked out via refs/tags/, verified against package.json and Cargo.toml versions before any toolchain setup, and Gitea commit statuses are posted against the tag commit rather than GITHUB_SHA (which is the dispatched branch head on workflow_dispatch).
This commit is contained in:
@@ -8,15 +8,59 @@ on:
|
|||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Existing release tag to build, for example v0.1.1'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
timeout-minutes: 120
|
||||||
env:
|
env:
|
||||||
|
CARGO_INCREMENTAL: 0
|
||||||
GITEA_STATUS_TOKEN: ${{ secrets.GITEA_STATUS_TOKEN }}
|
GITEA_STATUS_TOKEN: ${{ secrets.GITEA_STATUS_TOKEN }}
|
||||||
|
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
|
||||||
steps:
|
steps:
|
||||||
|
# refs/tags/ qualification: a branch with a tag-like name must never win
|
||||||
|
# ref resolution. Works for tag pushes too — RELEASE_TAG is the tag name.
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: refs/tags/${{ env.RELEASE_TAG }}
|
||||||
|
|
||||||
|
# On workflow_dispatch GITHUB_SHA is the dispatched branch head, not the
|
||||||
|
# tag's commit — resolve the real one for Gitea commit statuses.
|
||||||
|
- name: Resolve release commit
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
$sha = git rev-parse HEAD
|
||||||
|
"RELEASE_SHA=$sha" | Out-File -FilePath $env:GITHUB_ENV -Append
|
||||||
|
|
||||||
|
- name: Verify release version
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
if ($env:RELEASE_TAG -notmatch '^v\d+\.\d+\.\d+(-.+)?$') {
|
||||||
|
throw "Release tag '$env:RELEASE_TAG' must look like v0.1.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
$packageVersion = (Get-Content package.json -Raw | ConvertFrom-Json).version
|
||||||
|
$cargoVersion = (Select-String -Path src-tauri/Cargo.toml -Pattern '^version\s*=\s*"(.+)"').Matches[0].Groups[1].Value
|
||||||
|
|
||||||
|
if ($packageVersion -ne $cargoVersion) {
|
||||||
|
throw "package.json version ($packageVersion) does not match Cargo.toml version ($cargoVersion)"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($env:RELEASE_TAG -ne "v$packageVersion") {
|
||||||
|
throw "Release tag '$env:RELEASE_TAG' does not match project version v$packageVersion"
|
||||||
|
}
|
||||||
|
|
||||||
- name: Report pending status to Gitea
|
- name: Report pending status to Gitea
|
||||||
if: env.GITEA_STATUS_TOKEN != ''
|
if: env.GITEA_STATUS_TOKEN != ''
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
@@ -36,13 +80,11 @@ jobs:
|
|||||||
} | ConvertTo-Json
|
} | ConvertTo-Json
|
||||||
Invoke-RestMethod `
|
Invoke-RestMethod `
|
||||||
-Method Post `
|
-Method Post `
|
||||||
-Uri "https://git.jezz.wtf/api/v1/repos/JezzWTF/phokus/statuses/$env:GITHUB_SHA" `
|
-Uri "https://git.jezz.wtf/api/v1/repos/JezzWTF/phokus/statuses/$env:RELEASE_SHA" `
|
||||||
-Headers $headers `
|
-Headers $headers `
|
||||||
-ContentType "application/json" `
|
-ContentType "application/json" `
|
||||||
-Body $body
|
-Body $body
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: 11
|
version: 11
|
||||||
@@ -51,6 +93,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: 22
|
||||||
cache: pnpm
|
cache: pnpm
|
||||||
|
cache-dependency-path: pnpm-lock.yaml
|
||||||
|
|
||||||
- name: Install Rust stable
|
- name: Install Rust stable
|
||||||
uses: dtolnay/rust-toolchain@stable
|
uses: dtolnay/rust-toolchain@stable
|
||||||
@@ -71,7 +114,7 @@ jobs:
|
|||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
||||||
with:
|
with:
|
||||||
tagName: ${{ github.ref_name }}
|
tagName: ${{ env.RELEASE_TAG }}
|
||||||
releaseName: 'Phokus v__VERSION__'
|
releaseName: 'Phokus v__VERSION__'
|
||||||
releaseBody: 'See the assets below to download and install this version.'
|
releaseBody: 'See the assets below to download and install this version.'
|
||||||
releaseDraft: true
|
releaseDraft: true
|
||||||
@@ -105,9 +148,11 @@ jobs:
|
|||||||
description = "GitHub Actions release finished: $env:JOB_STATUS"
|
description = "GitHub Actions release finished: $env:JOB_STATUS"
|
||||||
target_url = $env:GITHUB_RUN_URL
|
target_url = $env:GITHUB_RUN_URL
|
||||||
} | ConvertTo-Json
|
} | ConvertTo-Json
|
||||||
|
# RELEASE_SHA is unset if the job died before checkout; fall back.
|
||||||
|
$sha = if ($env:RELEASE_SHA) { $env:RELEASE_SHA } else { $env:GITHUB_SHA }
|
||||||
Invoke-RestMethod `
|
Invoke-RestMethod `
|
||||||
-Method Post `
|
-Method Post `
|
||||||
-Uri "https://git.jezz.wtf/api/v1/repos/JezzWTF/phokus/statuses/$env:GITHUB_SHA" `
|
-Uri "https://git.jezz.wtf/api/v1/repos/JezzWTF/phokus/statuses/$sha" `
|
||||||
-Headers $headers `
|
-Headers $headers `
|
||||||
-ContentType "application/json" `
|
-ContentType "application/json" `
|
||||||
-Body $body
|
-Body $body
|
||||||
|
|||||||
Reference in New Issue
Block a user