-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (61 loc) · 2.5 KB
/
Copy pathbuild.yml
File metadata and controls
74 lines (61 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Build
on:
push:
branches:
- dev
- main
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: "25"
distribution: "zulu"
cache: "gradle"
- name: Make gradle wrapper executable
run: chmod +x ./gradlew
- name: Read mod version
id: mod_info
run: echo "mod_version=$(grep '^mod_version' gradle.properties | cut -d= -f2)" >> $GITHUB_OUTPUT
- name: Build all versions
run: |
mkdir -p dist
VERSION="${{ steps.mod_info.outputs.mod_version }}"
while read -r version_data; do
VER=$(echo "$version_data" | jq -r '.version')
MC_SRC=$(echo "$version_data" | jq -r '.mcVersion // .version')
MC_VER=$(echo "$version_data" | jq -r '.minecraft_version')
FABRIC_API=$(echo "$version_data" | jq -r '.fabric_api_version')
YARN=$(echo "$version_data" | jq -r '.yarn_mappings // empty')
LOADER=$(echo "$version_data" | jq -r '.loader_version // empty')
if [ ! -d "src/mc-${MC_SRC}" ]; then
echo "Skipping $VER (no src/mc-${MC_SRC})"
continue
fi
echo "Building $VER..."
PROP_ARGS=(-DmcVersion="$MC_SRC" -PmcVersion="$MC_SRC" -Pminecraft_version="$MC_VER" -Pfabric_api_version="$FABRIC_API")
[ -n "$YARN" ] && PROP_ARGS+=(-Pyarn_mappings="$YARN")
[ -n "$LOADER" ] && PROP_ARGS+=(-Ploader_version="$LOADER")
./gradlew clean build "${PROP_ARGS[@]}" --no-daemon -q 2>&1 || exit 1
cp "build/libs/stackabletools-${VERSION}.jar" "dist/stackabletools-${VERSION}-mc${VER}.jar"
done < <(jq -c '.versions[]' versions.json)
- name: Push artifacts to build branch
run: |
cd dist
git init
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git checkout -b build
git add .
git commit -m "Build v${{ steps.mod_info.outputs.mod_version }} - $(date +'%Y-%m-%d %H:%M:%S')"
git remote add origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
git push --force-with-lease origin build 2>/dev/null || git push -f origin build