Skip to content

Commit 83a69b8

Browse files
committed
fix: wrong trigger for release action
1 parent 66aa9cc commit 83a69b8

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

.github/workflows/release.yml

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
name: Nightly Build
1+
name: Build and Release
22
on:
33
push:
4-
branches: [main, master]
4+
tags:
5+
56
workflow_dispatch:
67

78
env:
@@ -13,32 +14,35 @@ jobs:
1314
runs-on: ubuntu-latest
1415
outputs:
1516
version: ${{ steps.version.outputs.version }}
16-
version_changed: ${{ steps.version.outputs.changed }}
17+
is_new_release: ${{ steps.version.outputs.is_new_release }}
1718
steps:
1819
- name: Checkout code
1920
uses: actions/checkout@v4
2021
with:
2122
fetch-depth: 0
2223

23-
- name: Get version from Cargo.toml
24+
- name: Get version
2425
id: version
2526
run: |
26-
VERSION=$(grep '^version =' Cargo.toml | head -n1 | sed 's/version = "//;s/"//')
27-
echo "version=v$VERSION" >> $GITHUB_OUTPUT
28-
echo "Version: v$VERSION"
27+
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == refs/tags/* ]]; then
2928
30-
if git tag --list | grep -q "^v$VERSION$"; then
31-
echo "changed=false" >> $GITHUB_OUTPUT
32-
echo "Tag v$VERSION already exists"
29+
echo "version=$VERSION" >> $GITHUB_OUTPUT
30+
echo "is_new_release=true" >> $GITHUB_OUTPUT
31+
echo "Version from tag: $VERSION"
3332
else
34-
echo "changed=true" >> $GITHUB_OUTPUT
35-
echo "New version detected: v$VERSION"
33+
34+
VERSION=$(grep '^version =' Cargo.toml | head -n1 | sed 's/version = "//;s/"//')
35+
VERSION="v$VERSION"
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
echo "is_new_release=true" >> $GITHUB_OUTPUT
38+
echo "Version from Cargo.toml: $VERSION"
3639
fi
3740
3841
build:
3942
name: Build (${{ matrix.display_name }})
4043
runs-on: ${{ matrix.os }}
4144
needs: get-version
45+
if: needs.get-version.outputs.is_new_release == 'true'
4246
strategy:
4347
matrix:
4448
include:
@@ -140,7 +144,7 @@ jobs:
140144
name: Create Release
141145
runs-on: ubuntu-latest
142146
needs: [get-version, build]
143-
if: needs.get-version.outputs.version_changed == 'true'
147+
if: needs.get-version.outputs.is_new_release == 'true'
144148
permissions:
145149
contents: write
146150
steps:
@@ -196,7 +200,7 @@ jobs:
196200
name: Publish to AUR
197201
runs-on: ubuntu-latest
198202
needs: [get-version, release]
199-
if: needs.get-version.outputs.version_changed == 'true'
203+
if: needs.get-version.outputs.is_new_release == 'true'
200204
steps:
201205
- name: Checkout code
202206
uses: actions/checkout@v4

0 commit comments

Comments
 (0)