From 60cde291bd0a0c7f9c59ac2e9de170cdd2657297 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Sat, 16 May 2026 12:34:26 +0700 Subject: [PATCH] ci: add windows release workflow --- .github/workflows/release.yml | 62 +++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d999528 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,62 @@ +name: Release + +on: + push: + tags: ['v*.*.*'] + workflow_dispatch: + inputs: + tag: + description: 'Tag to release (must already exist, e.g. v0.1.1)' + required: true + +permissions: + contents: write + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.tag || github.ref }} + + - uses: Swatinem/rust-cache@v2 + + - name: Resolve tag + id: tag + shell: pwsh + run: | + $tag = if ($env:GITHUB_REF -like 'refs/tags/*') { + $env:GITHUB_REF -replace '^refs/tags/','' + } else { + '${{ github.event.inputs.tag }}' + } + "tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + + - name: Verify Cargo.toml version matches tag + shell: pwsh + run: | + $tag = '${{ steps.tag.outputs.tag }}' + $expected = $tag -replace '^v','' + $cargoVersion = (Select-String -Path Cargo.toml -Pattern '^version\s*=\s*"([^"]+)"' | Select-Object -First 1).Matches.Groups[1].Value + if ($cargoVersion -ne $expected) { + Write-Error "Tag ($tag -> $expected) does not match Cargo.toml version ($cargoVersion). Bump Cargo.toml before tagging." + exit 1 + } + Write-Host "Cargo version $cargoVersion matches tag $tag" + + - name: Build release + run: cargo build --release --locked + + - name: Create release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: pwsh + run: | + $tag = '${{ steps.tag.outputs.tag }}' + $asset = 'target/release/claude-code-usage-bubble.exe' + if ('${{ github.event_name }}' -eq 'workflow_dispatch') { + gh release create $tag $asset --title $tag --generate-notes --draft + } else { + gh release create $tag $asset --title $tag --generate-notes + }