Skip to content

Commit 42cb78f

Browse files
committed
Update CI
1 parent 15060ec commit 42cb78f

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,70 @@ name: CI
22

33
on:
44
push:
5-
pull_request_target:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
8+
release:
9+
types: [ "published" ]
610

711
jobs:
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-
uses: softprops/[email protected]
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

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>com.github.jikoo</groupId>
88
<artifactId>anvilunlocker</artifactId>
99
<name>AnvilUnlocker</name>
10-
<version>1.1.0</version>
10+
<version>0.0.0-SNAPSHOT</version>
1111

1212
<properties>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -49,7 +49,7 @@
4949
</dependencies>
5050

5151
<build>
52-
<finalName>${project.name}</finalName>
52+
<finalName>${project.name}-${project.version}</finalName>
5353

5454
<resources>
5555
<resource>
@@ -59,4 +59,4 @@
5959
</resources>
6060
</build>
6161

62-
</project>
62+
</project>

0 commit comments

Comments
 (0)