Skip to content

Commit 063832e

Browse files
committed
Add github workflow
1 parent 4d75ac2 commit 063832e

File tree

2 files changed

+138
-0
lines changed

2 files changed

+138
-0
lines changed

.github/workflows/ci-build.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI Build (push / PR -> build + upload artifact)
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
with:
15+
persist-credentials: false
16+
fetch-depth: 0
17+
fetch-tags: true
18+
19+
- name: Set up JDK 17
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'temurin'
23+
java-version: '17'
24+
cache: 'gradle'
25+
26+
- name: Make gradlew executable
27+
run: chmod +x ./gradlew
28+
29+
- name: Ensure jar in fml-loom cache
30+
run: |
31+
set -euo pipefail
32+
MITE_VER="1.6.4-MITE"
33+
GRADLE_USER_HOME="${GRADLE_USER_HOME:-$HOME/.gradle}"
34+
CACHE_DIR="$GRADLE_USER_HOME/caches/fml-loom/$MITE_VER"
35+
TARGET_JAR="$CACHE_DIR/$MITE_VER.jar"
36+
37+
mkdir -p "$CACHE_DIR"
38+
39+
if [ -f "$TARGET_JAR" ]; then
40+
echo "Found $TARGET_JAR, skipping download."
41+
exit 0
42+
fi
43+
44+
DOWNLOAD_URL="https://maven.limingzxc.top/repository/maven-releases/com/mojang/minecraft/$MITE_VER/minecraft-$MITE_VER.jar"
45+
46+
echo "Downloading $DOWNLOAD_URL ..."
47+
# download to temp file then move into place
48+
curl -fSL "$DOWNLOAD_URL" -o "$TARGET_JAR.tmp"
49+
mv "$TARGET_JAR.tmp" "$TARGET_JAR"
50+
echo "Saved $TARGET_JAR"
51+
52+
- name: Build with Gradle
53+
run: ./gradlew clean build --no-daemon
54+
55+
- name: Find built JAR
56+
id: find
57+
run: |
58+
set -e
59+
ARTIFACTS=$(ls build/libs/*.jar 2>/dev/null || true)
60+
if [ -z "$ARTIFACTS" ]; then
61+
echo "No jar found in build/libs/"
62+
exit 1
63+
fi
64+
# output all matching paths (newline-separated)
65+
echo "$ARTIFACTS" | tr ' ' '\n' > artifact_paths.txt
66+
echo "artifact_list<<EOF" >> $GITHUB_OUTPUT
67+
cat artifact_paths.txt >> $GITHUB_OUTPUT
68+
echo "EOF" >> $GITHUB_OUTPUT
69+
70+
- name: Upload Build Artifacts
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: build-artifacts-${{ github.sha }}
74+
path: build/libs/*.jar
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Release on tag
2+
3+
permissions:
4+
contents: write
5+
issues: write
6+
7+
on:
8+
push:
9+
tags:
10+
- '*'
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
persist-credentials: false
21+
fetch-depth: 0
22+
fetch-tags: true
23+
24+
- name: Set up JDK 17
25+
uses: actions/setup-java@v4
26+
with:
27+
distribution: 'temurin'
28+
java-version: '17'
29+
cache: 'gradle'
30+
31+
- name: Make gradlew executable
32+
run: chmod +x ./gradlew
33+
34+
- name: Ensure jar in fml-loom cache
35+
run: |
36+
set -euo pipefail
37+
MITE_VER="1.6.4-MITE"
38+
GRADLE_USER_HOME="${GRADLE_USER_HOME:-$HOME/.gradle}"
39+
CACHE_DIR="$GRADLE_USER_HOME/caches/fml-loom/$MITE_VER"
40+
TARGET_JAR="$CACHE_DIR/$MITE_VER.jar"
41+
42+
mkdir -p "$CACHE_DIR"
43+
44+
if [ -f "$TARGET_JAR" ]; then
45+
echo "Found $TARGET_JAR, skipping download."
46+
exit 0
47+
fi
48+
49+
DOWNLOAD_URL="https://maven.limingzxc.top/repository/maven-releases/com/mojang/minecraft/$MITE_VER/minecraft-$MITE_VER.jar"
50+
51+
echo "Downloading $DOWNLOAD_URL ..."
52+
# download to temp file then move into place
53+
curl -fSL "$DOWNLOAD_URL" -o "$TARGET_JAR.tmp"
54+
mv "$TARGET_JAR.tmp" "$TARGET_JAR"
55+
echo "Saved $TARGET_JAR"
56+
57+
- name: Build
58+
run: ./gradlew build
59+
60+
- name: Create GitHub Release
61+
uses: ncipollo/release-action@v1.14.0
62+
with:
63+
artifacts: "build/libs/*.jar"
64+
generateReleaseNotes: true

0 commit comments

Comments
 (0)