@@ -2,65 +2,70 @@ name: CI
22
33on :
44 push :
5- pull_request_target :
5+ branches : [ "master" ]
6+ pull_request :
7+ branches : [ "master" ]
8+ release :
9+ types : [ "published" ]
610
711jobs :
812 build :
13+ name : Build
914 runs-on : ubuntu-latest
15+ outputs :
16+ VERSION : ${{ steps.version.outputs.VERSION }}
1017 steps :
1118 - name : Checkout Code
12- uses : actions/checkout@v2
19+ uses : actions/checkout@v4
20+ with :
21+ fetch-depth : 0
22+ fetch-tags : " true"
1323
1424 - name : Set Up Java
15- uses : actions/setup-java@v2
25+ uses : actions/setup-java@v4
1626 with :
17- distribution : ' adopt '
18- java-version : ' 17 '
27+ distribution : " temurin "
28+ java-version : " 17 "
1929
2030 # Use cache to speed up build
2131 - name : Cache Maven Repo
22- uses : actions/cache@v2
32+ uses : actions/cache@v4
2333 id : cache
2434 with :
2535 path : ~/.m2/repository
2636 key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
2737
38+ - name : Get version
39+ run : |
40+ TAG=$(git describe --tags --always)
41+ echo "VERSION=${TAG#v}" >> $GITHUB_OUTPUT
42+ id : version
43+
44+ - name : Set version
45+ run : mvn -B versions:set -DnewVersion=${{ steps.version.outputs.VERSION }} -DgenerateBackupPoms=false
46+
2847 - name : Build With Maven
2948 run : mvn -e clean package -am -P all
3049
31- # Upload artifacts
3250 - name : Upload Distributable Jar
3351 id : upload-final
34- uses : actions/upload-artifact@v2
52+ uses : actions/upload-artifact@v4
3553 with :
3654 name : dist
37- path : ./target/AnvilUnlocker.jar
55+ path : ./target/AnvilUnlocker-${{ steps.version.outputs.VERSION }} .jar
3856
3957 release :
4058 name : Create Github Release
4159 needs : [ build ]
42- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
60+ if : github.event_name == 'release'
4361 runs-on : ubuntu-latest
4462 steps :
45- - name : Checkout Code
46- uses : actions/checkout@v2
47- with :
48- fetch-depth : 0
49-
5063 - name : Download Artifacts
51- uses : actions/download-artifact@v2
64+ uses : actions/download-artifact@v4
5265
53- - name : Parse Tag Name
54- id : get_version
55- run : echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
56-
57- - name : Create Release
58- id : create-release
59- 66+ - name : Upload to release
67+ uses : JasonEtco/upload-to-release@master
68+ with :
69+ args : ./dist/AnvilUnlocker-${{ needs.build.outputs.VERSION }}.jar application/java-archive
6070 env :
6171 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
62- with :
63- name : AnvilUnlocker ${{ steps.get_version.outputs.result }}
64- draft : true
65- prerelease : true
66- files : ./dist/AnvilUnlocker.jar
0 commit comments