Skip to content

Commit 3910b20

Browse files
committed
👷 Update release workflow
1 parent 717a5f7 commit 3910b20

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
name: release
22
on:
33
push:
4-
tags:
5-
- "v[0-9]+.[0-9]+.[0-9]+"
4+
branches:
5+
- main
66

77
concurrency:
88
group: ${{ github.sha }}
99
cancel-in-progress: true
1010

1111
jobs:
1212
build-release:
13-
name: build-release ${{ matrix.os }}
13+
name: build-release ${{ matrix.os }} ${{ matrix.rust }} ${{ matrix.target }}
1414
runs-on: ${{ matrix.os }}
1515
timeout-minutes: 5
1616
strategy:
@@ -24,19 +24,36 @@ jobs:
2424
os: macos-latest
2525
rust: stable
2626
target: x86_64-apple-darwin
27+
- build: macos-arm64
28+
os: macos-latest
29+
rust: stable
30+
target: aarch64-apple-darwin
2731
env:
2832
RUST_BACKTRACE: full
2933
TARGET_DIR: ./target
3034
steps:
3135
- name: Checkout repository
3236
uses: actions/checkout@v2
3337

34-
- name: Get the release version from the tag
38+
- name: Determine version changes
39+
id: version_check
3540
shell: bash
36-
if: env.FLOPHA_VERSION == ''
3741
run: |
38-
echo "FLOPHA_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
39-
echo "version is: ${{ env.FLOPHA_VERSION }}"
42+
latest_release=$(curl -s -H "Authorization: token ${{ github.token }}" \
43+
https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name')
44+
echo "Latest release version: $latest_release"
45+
46+
cargo_version=$(grep -m1 '^version\s*=' Cargo.toml | awk -F '"' '{print $2}')
47+
echo "Cargo version: $cargo_version"
48+
49+
if [ "$latest_version" != "$cargo_version" ]; then
50+
echo "Version has changed to $cargo_version"
51+
echo "version_changed=true" >> $GITHUB_OUTPUT
52+
echo "NEW_VERSION=$cargo_version" >> $GITHUB_ENV
53+
else
54+
echo "Version has not changed"
55+
echo "version_changed=false" >> $GITHUB_OUTPUT
56+
fi
4057
4158
- name: Install packages (Ubuntu)
4259
if: matrix.os == 'ubuntu-20.04'
@@ -51,6 +68,12 @@ jobs:
5168
profile: minimal
5269
override: true
5370

71+
- name: Skip if version has not changed
72+
if: steps.version_check.outputs.version_changed != 'true'
73+
run: |
74+
echo "Version has not changed, skipping release"
75+
exit 78
76+
5477
- name: Build and Package
5578
shell: bash
5679
run: |
@@ -60,6 +83,6 @@ jobs:
6083
- name: Upload release archive
6184
uses: softprops/action-gh-release@v2
6285
with:
63-
tag_name: ${{ env.FLOPHA_VERSION }}
86+
tag_name: ${{ env.NEW_VERSION }}
6487
generate_release_notes: True
6588
files: ${{ env.ASSET }}

0 commit comments

Comments
 (0)