Fix CI release upload: support versioned releases on tag pushes
Some checks failed
Build macOS / Build (macOS) (push) Successful in 4m43s
Build Windows / Build (Windows) (push) Successful in 18m20s
Build Linux / Build (Linux) (push) Has been cancelled

- Upload step now runs on both main pushes and v* tag pushes
- Tag pushes create a versioned release (e.g., "Voice to Notes v0.2.0")
- Main pushes update the "latest" prerelease as before
- Windows: filter for *-setup.exe to avoid uploading non-installer binaries

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-03-21 11:03:00 -07:00
parent a0cb034ab5
commit ec7e364165
3 changed files with 49 additions and 12 deletions

View File

@@ -66,14 +66,26 @@ jobs:
# ── Release ── # ── Release ──
- name: Upload to release - name: Upload to release
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
env: env:
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }} BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
run: | run: |
sudo apt-get install -y jq sudo apt-get install -y jq
TAG="latest"
REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
# Use version tag for tag pushes, "latest" for main
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
RELEASE_NAME="Voice to Notes ${TAG}"
PRERELEASE=false
else
TAG="latest"
RELEASE_NAME="Voice to Notes (Latest Build)"
PRERELEASE=true
fi
echo "Release tag: ${TAG}"
RELEASE_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \ RELEASE_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \
"${REPO_API}/releases/tags/${TAG}" | jq -r '.id // empty') "${REPO_API}/releases/tags/${TAG}" | jq -r '.id // empty')
@@ -81,7 +93,7 @@ jobs:
RELEASE_ID=$(curl -s -X POST \ RELEASE_ID=$(curl -s -X POST \
-H "Authorization: token ${BUILD_TOKEN}" \ -H "Authorization: token ${BUILD_TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"tag_name\": \"${TAG}\", \"name\": \"Voice to Notes (Latest Build)\", \"body\": \"Latest automated build from main branch.\", \"draft\": false, \"prerelease\": true}" \ -d "{\"tag_name\": \"${TAG}\", \"name\": \"${RELEASE_NAME}\", \"body\": \"Automated build.\", \"draft\": false, \"prerelease\": ${PRERELEASE}}" \
"${REPO_API}/releases" | jq -r '.id') "${REPO_API}/releases" | jq -r '.id')
fi fi

View File

@@ -65,13 +65,25 @@ jobs:
# ── Release ── # ── Release ──
- name: Upload to release - name: Upload to release
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
env: env:
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }} BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
run: | run: |
TAG="latest"
REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}" REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
# Use version tag for tag pushes, "latest" for main
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
RELEASE_NAME="Voice to Notes ${TAG}"
PRERELEASE=false
else
TAG="latest"
RELEASE_NAME="Voice to Notes (Latest Build)"
PRERELEASE=true
fi
echo "Release tag: ${TAG}"
RELEASE_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \ RELEASE_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \
"${REPO_API}/releases/tags/${TAG}" | jq -r '.id // empty') "${REPO_API}/releases/tags/${TAG}" | jq -r '.id // empty')
@@ -79,7 +91,7 @@ jobs:
RELEASE_ID=$(curl -s -X POST \ RELEASE_ID=$(curl -s -X POST \
-H "Authorization: token ${BUILD_TOKEN}" \ -H "Authorization: token ${BUILD_TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"tag_name\": \"${TAG}\", \"name\": \"Voice to Notes (Latest Build)\", \"body\": \"Latest automated build from main branch.\", \"draft\": false, \"prerelease\": true}" \ -d "{\"tag_name\": \"${TAG}\", \"name\": \"${RELEASE_NAME}\", \"body\": \"Automated build.\", \"draft\": false, \"prerelease\": ${PRERELEASE}}" \
"${REPO_API}/releases" | jq -r '.id') "${REPO_API}/releases" | jq -r '.id')
fi fi

View File

@@ -75,25 +75,38 @@ jobs:
# ── Release ── # ── Release ──
- name: Upload to release - name: Upload to release
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
shell: powershell shell: powershell
env: env:
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }} BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
run: | run: |
$TAG = "latest"
$REPO_API = "${{ github.server_url }}/api/v1/repos/${{ github.repository }}" $REPO_API = "${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
$Headers = @{ "Authorization" = "token $env:BUILD_TOKEN" } $Headers = @{ "Authorization" = "token $env:BUILD_TOKEN" }
# Use version tag for tag pushes, "latest" for main
$REF = "${{ github.ref }}"
if ($REF.StartsWith("refs/tags/")) {
$TAG = $REF.Replace("refs/tags/", "")
$RELEASE_NAME = "Voice to Notes ${TAG}"
$PRERELEASE = $false
} else {
$TAG = "latest"
$RELEASE_NAME = "Voice to Notes (Latest Build)"
$PRERELEASE = $true
}
Write-Host "Release tag: ${TAG}"
try { try {
$release = Invoke-RestMethod -Uri "${REPO_API}/releases/tags/${TAG}" -Headers $Headers -ErrorAction Stop $release = Invoke-RestMethod -Uri "${REPO_API}/releases/tags/${TAG}" -Headers $Headers -ErrorAction Stop
$RELEASE_ID = $release.id $RELEASE_ID = $release.id
} catch { } catch {
$body = @{ $body = @{
tag_name = $TAG tag_name = $TAG
name = "Voice to Notes (Latest Build)" name = $RELEASE_NAME
body = "Latest automated build from main branch." body = "Automated build."
draft = $false draft = $false
prerelease = $true prerelease = $PRERELEASE
} | ConvertTo-Json } | ConvertTo-Json
$release = Invoke-RestMethod -Uri "${REPO_API}/releases" -Method Post -Headers $Headers -ContentType "application/json" -Body $body $release = Invoke-RestMethod -Uri "${REPO_API}/releases" -Method Post -Headers $Headers -ContentType "application/json" -Body $body
$RELEASE_ID = $release.id $RELEASE_ID = $release.id
@@ -101,7 +114,7 @@ jobs:
Write-Host "Release ID: ${RELEASE_ID}" Write-Host "Release ID: ${RELEASE_ID}"
Get-ChildItem -Path src-tauri\target\release\bundle -Recurse -Include *.msi,*.exe | ForEach-Object { Get-ChildItem -Path src-tauri\target\release\bundle -Recurse -Include *.msi,*-setup.exe | ForEach-Object {
$filename = $_.Name $filename = $_.Name
$encodedName = [System.Uri]::EscapeDataString($filename) $encodedName = [System.Uri]::EscapeDataString($filename)
$size = [math]::Round($_.Length / 1MB, 1) $size = [math]::Round($_.Length / 1MB, 1)