9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-26 10:29:13 +00:00
Files
Leaf/.github/workflows/build-1214.yml
2025-03-10 21:57:15 +01:00

136 lines
4.9 KiB
YAML

name: Build Leaf 1.21.4
on:
push:
branches: [ "ver/1.21.4" ]
workflow_dispatch:
jobs:
build:
runs-on: blacksmith-8vcpu-ubuntu-2204
env:
BUILD_NUMBER: ${{ github.run_number }}
GRADLE_MEMORY: "-Xmx4g -XX:MaxMetaspaceSize=2g"
outputs:
build_number: ${{ env.BUILD_NUMBER }}
steps:
- name: Checkout repository
uses: actions/checkout@main
with:
fetch-depth: 0
- name: Setup Gradle Cache
uses: useblacksmith/cache@v5
with:
path: |
~/.gradle/caches/modules-2
~/.gradle/caches/jars-*
~/.gradle/caches/transforms-*
~/.gradle/wrapper
~/.gradle/build-cache-*
~/.gradle/configuration-cache-*
.gradle/patchCache
.gradle/patched
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'buildSrc/**/*.kt', 'patches/**/*.patch') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Gradle Cache Cleanup
run: |
mkdir -p ~/.gradle/caches/modules-2
[ -f ~/.gradle/caches/modules-2/modules-2.lock ] && rm -f ~/.gradle/caches/modules-2/modules-2.lock
find ~/.gradle/caches -name "*.lock" -type f -delete || echo "No lock files found"
- name: Setup java
uses: useblacksmith/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Configure Git
run: |
git config --global user.email "no-reply@github.com"
git config --global user.name "Github Actions"
git config --global core.preloadindex true
git config --global core.fscache true
git config --global gc.auto 256
- name: Configure Gradle Properties
run: |
mkdir -p ~/.gradle
echo "org.gradle.daemon=true" >> ~/.gradle/gradle.properties
echo "org.gradle.parallel=true" >> ~/.gradle/gradle.properties
echo "org.gradle.caching=true" >> ~/.gradle/gradle.properties
echo "org.gradle.jvmargs=${{ env.GRADLE_MEMORY }} -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" >> ~/.gradle/gradle.properties
echo "kotlin.incremental=true" >> ~/.gradle/gradle.properties
- name: Apply patches
run: |
PARALLELISM=$(($(nproc) * 2))
./gradlew -Dorg.gradle.jvmargs="${{ env.GRADLE_MEMORY }}" \
-Dleaf.patcher.parallelism=$PARALLELISM \
-Dleaf.patcher.incremental=true \
applyAllPatches \
--stacktrace --parallel \
--max-workers=$PARALLELISM \
--build-cache \
--configuration-cache \
--no-configuration-cache-question
- name: Create MojmapPaperclipJar
run: ./gradlew createMojmapPaperclipJar --stacktrace --parallel
- name: Create ReobfPaperclipJar
run: ./gradlew -Dpaperweight.debug=true createReobfPaperclipJar --stacktrace --parallel
- name: Start API Publishing
id: publish-api
run: |
(
./gradlew publish --parallel --max-workers=4 > publish_api_log.txt 2>&1
echo "API_PUBLISH_DONE=true" >> $GITHUB_ENV
) &
echo "PUBLISH_PID=$!" >> $GITHUB_ENV
env:
REPO_USER: ${{ secrets.REPO_USER }}
REPO_PASSWORD: ${{ secrets.REPO_PASSWORD }}
- name: Rename Paperclip JARs
run: |
mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-mojmap.jar ./leaf-1.21.4-${{ env.BUILD_NUMBER }}-mojmap.jar
mv leaf-server/build/libs/leaf-paperclip-1.21.4-R0.1-SNAPSHOT-reobf.jar ./leaf-1.21.4-${{ env.BUILD_NUMBER }}-reobf.jar
- name: Upload Leaf as build artifact
uses: actions/upload-artifact@main
with:
name: Leaf 1.21.4
path: ./leaf-1.21.4-*.jar
- name: Prepare release notes and artifacts
run: |
chmod +x ./scripts/prepareRelease.sh
./scripts/prepareRelease.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
BUILD_NUMBER: ${{ env.BUILD_NUMBER }}
- name: Wait for API Publishing
run: |
if ps -p ${{ env.PUBLISH_PID }} > /dev/null; then
wait ${{ env.PUBLISH_PID }} || true
fi
grep -i "error" publish_api_log.txt && echo "Found errors in log" || echo "No errors found"
- name: Release Leaf
uses: softprops/action-gh-release@master
with:
name: "Leaf 1.21.4"
tag_name: "ver-1.21.4"
files: "./leaf-1.21.4-${{ env.BUILD_NUMBER }}.jar"
body_path: "./release_notes.md"
token: "${{ secrets.GITHUB_TOKEN }}"
target_commitish: "${{ github.sha }}"
prerelease: false