Fix duplicate CI runs: remove tags trigger, detect tags on commit
Pushing to main + a tag triggered 6 workflows (3 per trigger). Now only main pushes trigger builds. The upload step detects version tags on the current commit via git tag --points-at HEAD. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,6 @@ name: Build Linux
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
tags: ["v*"]
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
@@ -66,16 +65,17 @@ jobs:
|
|||||||
|
|
||||||
# ── Release ──
|
# ── Release ──
|
||||||
- name: Upload to release
|
- name: Upload to release
|
||||||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
|
if: github.ref == 'refs/heads/main'
|
||||||
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
|
||||||
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
|
# Check if the current commit has a version tag
|
||||||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
VERSION_TAG=$(git tag --points-at HEAD | grep '^v' | head -1)
|
||||||
TAG="${GITHUB_REF#refs/tags/}"
|
if [ -n "${VERSION_TAG}" ]; then
|
||||||
|
TAG="${VERSION_TAG}"
|
||||||
RELEASE_NAME="Voice to Notes ${TAG}"
|
RELEASE_NAME="Voice to Notes ${TAG}"
|
||||||
PRERELEASE=false
|
PRERELEASE=false
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ name: Build macOS
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
tags: ["v*"]
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
@@ -65,15 +64,16 @@ jobs:
|
|||||||
|
|
||||||
# ── Release ──
|
# ── Release ──
|
||||||
- name: Upload to release
|
- name: Upload to release
|
||||||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
|
if: github.ref == 'refs/heads/main'
|
||||||
env:
|
env:
|
||||||
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
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
|
# Check if the current commit has a version tag
|
||||||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
VERSION_TAG=$(git tag --points-at HEAD | grep '^v' | head -1)
|
||||||
TAG="${GITHUB_REF#refs/tags/}"
|
if [ -n "${VERSION_TAG}" ]; then
|
||||||
|
TAG="${VERSION_TAG}"
|
||||||
RELEASE_NAME="Voice to Notes ${TAG}"
|
RELEASE_NAME="Voice to Notes ${TAG}"
|
||||||
PRERELEASE=false
|
PRERELEASE=false
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ name: Build Windows
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
tags: ["v*"]
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
@@ -75,7 +74,7 @@ jobs:
|
|||||||
|
|
||||||
# ── Release ──
|
# ── Release ──
|
||||||
- name: Upload to release
|
- name: Upload to release
|
||||||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
|
if: github.ref == 'refs/heads/main'
|
||||||
shell: powershell
|
shell: powershell
|
||||||
env:
|
env:
|
||||||
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
||||||
@@ -83,10 +82,10 @@ jobs:
|
|||||||
$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
|
# Check if the current commit has a version tag
|
||||||
$REF = "${{ github.ref }}"
|
$VERSION_TAG = (git tag --points-at HEAD | Select-String '^v').Line
|
||||||
if ($REF.StartsWith("refs/tags/")) {
|
if ($VERSION_TAG) {
|
||||||
$TAG = $REF.Replace("refs/tags/", "")
|
$TAG = $VERSION_TAG
|
||||||
$RELEASE_NAME = "Voice to Notes ${TAG}"
|
$RELEASE_NAME = "Voice to Notes ${TAG}"
|
||||||
$PRERELEASE = $false
|
$PRERELEASE = $false
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user