Skip to content

Commit 449ffa6

Browse files
authored
Merge pull request #78 from MrButtersDEV/dev
GitHub - Actions
2 parents 284baa3 + 3e4e3e6 commit 449ffa6

File tree

2 files changed

+75
-2
lines changed

2 files changed

+75
-2
lines changed

.github/workflows/build.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Dev Build
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: 📦 Checkout Code
14+
uses: actions/checkout@v3
15+
16+
- name: ☕ Set up Java 21
17+
uses: actions/setup-java@v3
18+
with:
19+
distribution: temurin
20+
java-version: 21
21+
22+
- name: 🏷 Get current base version from pom.xml
23+
id: version
24+
run: |
25+
BASE_VERSION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)
26+
echo "BASE_VERSION=${BASE_VERSION%%-DEVBUILD*}" >> $GITHUB_ENV
27+
echo "base_version=${BASE_VERSION%%-DEVBUILD*}" >> $GITHUB_OUTPUT
28+
29+
- name: 🔢 Get last dev build number
30+
id: get-devbuild
31+
run: |
32+
VERSION_FILE=".github/devbuild-count.txt"
33+
VERSION="${{ steps.version.outputs.base_version }}"
34+
mkdir -p .github
35+
touch "$VERSION_FILE"
36+
37+
CURRENT=$(grep "^$VERSION=" "$VERSION_FILE" | cut -d= -f2)
38+
if [ -z "$CURRENT" ]; then
39+
CURRENT=1
40+
else
41+
CURRENT=$((CURRENT + 1))
42+
fi
43+
44+
echo "$VERSION=$CURRENT" > "$VERSION_FILE"
45+
echo "DEVBUILD=$CURRENT" >> $GITHUB_ENV
46+
echo "build_num=$CURRENT" >> $GITHUB_OUTPUT
47+
48+
- name: 🛠 Build with Maven
49+
run: |
50+
VERSION="${{ env.BASE_VERSION }}-DEVBUILD.${{ steps.get-devbuild.outputs.build_num }}"
51+
echo "Building version: $VERSION"
52+
mvn clean package -Drevision=$VERSION
53+
54+
- name: 📦 Rename and move JAR to dist/
55+
run: |
56+
mkdir -p dist
57+
JAR=$(find target -name "AutoPickup-*.jar" ! -name "*-original.jar" | head -n1)
58+
59+
if [ -z "$JAR" ]; then
60+
echo "❌ No JAR found in target/"
61+
ls -l target
62+
exit 1
63+
fi
64+
65+
cp "$JAR" "dist/AutoPickup-${{ env.BASE_VERSION }}-DEVBUILD.${{ steps.get-devbuild.outputs.build_num }}.jar"
66+
67+
68+
- name: 📥 Upload Dev Build Artifact
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: AutoPickup-${{ env.BASE_VERSION }}-DEVBUILD.${{ steps.get-devbuild.outputs.build_num }}
72+
path: dist/*.jar

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66

77
<groupId>us.thezircon.play</groupId>
88
<artifactId>AutoPickup</artifactId>
9-
<version>1.4.7-DEVBUILD.4</version>
9+
<version>${revision}</version>
1010
<packaging>jar</packaging>
1111

1212
<name>AutoPickup</name>
1313

1414
<description>Automatically picks up the blocks you mine!</description>
1515
<properties>
16+
<revision>1.4.7-DEVBUILD.4</revision>
1617
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1718
</properties>
1819
<url>https://discord.gg/ncHH4FP</url>
@@ -120,4 +121,4 @@
120121
<scope>provided</scope>
121122
</dependency>
122123
</dependencies>
123-
</project>
124+
</project>

0 commit comments

Comments
 (0)