Skip to content

Commit 73d7d46

Browse files
committed
Update workflow to trigger on release events and enforce tag-based conditional builds
- Adjusts the GitHub Actions workflow to run on published release events instead of tag pushes. - Adds conditional checks to ensure builds and publishing are only executed for tags starting with 'v'. - Automates version setting from release tags in `gradle.properties`.
1 parent 3201c2a commit 73d7d46

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

.github/workflows/publish-on-maven.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: Publish to Maven Central
22

33
on:
4-
push:
5-
tags:
6-
- "**"
4+
release:
5+
types: [published]
76

87
jobs:
98
build-rust-macos-aarch64:
9+
if: startsWith(github.event.release.tag_name, 'v')
1010
runs-on: macos-14
1111
steps:
1212
- name: Checkout code
@@ -27,6 +27,7 @@ jobs:
2727
retention-days: 1
2828

2929
build-rust-macos-x86_64:
30+
if: startsWith(github.event.release.tag_name, 'v')
3031
runs-on: macos-13
3132
steps:
3233
- name: Checkout code
@@ -47,6 +48,7 @@ jobs:
4748
retention-days: 1
4849

4950
build-rust-linux:
51+
if: startsWith(github.event.release.tag_name, 'v')
5052
runs-on: ubuntu-latest
5153
steps:
5254
- name: Checkout code
@@ -72,6 +74,7 @@ jobs:
7274
retention-days: 1
7375

7476
build-rust-windows:
77+
if: startsWith(github.event.release.tag_name, 'v')
7578
runs-on: windows-latest
7679
steps:
7780
- name: Checkout code
@@ -92,6 +95,7 @@ jobs:
9295
retention-days: 1
9396

9497
publish:
98+
if: startsWith(github.event.release.tag_name, 'v')
9599
needs:
96100
- build-rust-macos-aarch64
97101
- build-rust-macos-x86_64
@@ -101,6 +105,14 @@ jobs:
101105
steps:
102106
- name: Checkout code
103107
uses: actions/checkout@v4
108+
- name: Set version from tag
109+
shell: bash
110+
run: |
111+
TAG="${{ github.event.release.tag_name }}"
112+
VERSION_NAME="${TAG#v}"
113+
echo "VERSION_NAME=$VERSION_NAME" >> "$GITHUB_ENV"
114+
sed -i.bak "s/^VERSION_NAME=.*/VERSION_NAME=$VERSION_NAME/" gradle.properties
115+
rm -f gradle.properties.bak
104116
105117
- name: Download macOS aarch64 native library
106118
uses: actions/download-artifact@v4

0 commit comments

Comments
 (0)