11name : Build release
22
3- on :
3+ on :
44 push :
55 tags :
6- - ' *'
7- release :
8- types : [ published ]
6+ - ' *'
97 workflow_dispatch :
108
119jobs :
@@ -14,47 +12,60 @@ jobs:
1412 permissions :
1513 contents : write
1614 steps :
17-
15+
1816 - uses : actions/checkout@v5
19-
17+ with :
18+ fetch-depth : 0
19+
2020 - name : Setup up JDK 21
2121 uses : actions/setup-java@v5
2222 with :
2323 java-version : ' 21'
2424 distribution : ' temurin'
25-
25+
2626 - name : Setup Gradle
2727 uses : gradle/actions/setup-gradle@v5
2828 with :
29- cache-read-only : ${{ github.ref != 'refs/heads/main ' }}
30-
29+ cache-read-only : ${{ github.ref != 'refs/heads/master ' }}
30+
3131 - name : Read version from gradle.properties
3232 id : gradle_props
3333 run : |
3434 VERSION=$(grep "^version" gradle.properties | cut -d'=' -f2 | tr -d '[:space:]')
3535 echo "version=$VERSION" >> $GITHUB_OUTPUT
3636 echo "Version: $VERSION"
37-
37+
38+ - name : Create tag if not exists
39+ run : |
40+ VERSION=${{ steps.gradle_props.outputs.version }}
41+
42+ if git rev-parse "$VERSION" >/dev/null 2>&1; then
43+ echo "Tag already exists"
44+ else
45+ git config user.name "github-actions"
46+ git config user.email "github-actions@github.com"
47+ git tag $VERSION
48+ git push origin $VERSION -o ci.skip
49+ fi
50+
3851 - name : Build with Gradle
3952 run : ./gradlew build
40-
53+
4154 - name : Upload JAR as artifact
4255 uses : actions/upload-artifact@v4
4356 with :
4457 name : SAPI-${{ steps.gradle_props.outputs.version }}
45- path : build/libs/SAPI *.jar
46-
58+ path : build/libs/*.jar
59+
4760 - name : Create or Update Release
48- if : startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
4961 uses : softprops/action-gh-release@v2
5062 with :
51- name : Release ${{ steps.gradle_props.outputs.version }}
52- tag_name : ${{ github.ref_name }}
63+ name : ${{ steps.gradle_props.outputs.version }}
5364 files : build/libs/*.jar
65+ tag_name : ${{ steps.gradle_props.outputs.version }}
5466 generate_release_notes : true
5567 fail_on_unmatched_files : false
5668 draft : false
57- prerelease : ${{ contains(github.ref_name , 'beta') || contains(github.ref_name , 'alpha') }}
69+ prerelease : ${{ contains(steps.gradle_props.outputs.version , 'beta') || contains(steps.gradle_props.outputs.version , 'alpha') || contains(steps.gradle_props.outputs.version, 'SNAPSHOT ') }}
5870 env :
5971 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60-
0 commit comments