mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-27 02:49:19 +00:00
* [ci/skip] Cleanup workflow & Update relaeses * Correct output jar name * Correct format * Cleanup publish API * Upload tag retrival test * Fix * test * Fix build * Update release notes scripts * Fix github env * Fix * Fix format * Add missing env * Update workflow for test * Update prepareRelease.sh * Update workflow for test * Fix * Use full commit hash for commit log link & Format * [ci/skip] Ready for merge
177 lines
7.4 KiB
YAML
177 lines
7.4 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 }}
|
|
GRAALVM_ARGS: "-Dgraal.CompilerConfiguration=enterprise -Dgraal.UsePriorityInlining=true -Dgraal.Vectorization=true -Dgraal.OptDuplication=true -Dgraal.LoopUnroll=true -Dgraal.SpeculativeGuardMovement=true --add-modules jdk.incubator.vector"
|
|
GRADLE_MEMORY: "-Xmx4g -XX:MaxMetaspaceSize=2g"
|
|
PATCH_PARALLELISM: "16"
|
|
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
|
|
# Add patches 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
|
|
[ -f ~/.gradle/caches/modules-2/gc.properties ] && rm -f ~/.gradle/caches/modules-2/gc.properties
|
|
find ~/.gradle/caches -name "*.lock" -type f -delete || echo "No lock files found to delete"
|
|
|
|
- name: Set up GraalVM JDK 21
|
|
uses: graalvm/setup-graalvm@main
|
|
with:
|
|
java-version: 21
|
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
|
|
|
- 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"
|
|
# Speed up git operations
|
|
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
|
|
# Add patch parallelism configuration
|
|
echo "leafPatches.parallelism=${{ env.PATCH_PARALLELISM }}" >> ~/.gradle/gradle.properties
|
|
|
|
- name: Apply patches
|
|
run: |
|
|
# Analyze available system resources for optimal settings
|
|
echo "CPU cores: $(nproc)"
|
|
echo "Memory: $(free -h)"
|
|
|
|
# Run patch application with optimized settings
|
|
./gradlew -Dorg.gradle.jvmargs="${{ env.GRAALVM_ARGS }} ${{ env.GRADLE_MEMORY }}" \
|
|
-Dleaf.patcher.parallelism=${{ env.PATCH_PARALLELISM }} \
|
|
applyAllPatches \
|
|
--stacktrace --no-daemon --parallel \
|
|
--max-workers=8
|
|
|
|
- name: Create MojmapPaperclipJar
|
|
run: ./gradlew -Dorg.gradle.jvmargs="${{ env.GRAALVM_ARGS }} ${{ env.GRADLE_MEMORY }}" createMojmapPaperclipJar --stacktrace --no-daemon --parallel --max-workers=8
|
|
|
|
- name: Create ReobfPaperclipJar
|
|
run: ./gradlew -Dorg.gradle.jvmargs="${{ env.GRAALVM_ARGS }} ${{ env.GRADLE_MEMORY }}" -Dpaperweight.debug=true createReobfPaperclipJar --stacktrace --no-daemon --parallel --max-workers=8
|
|
|
|
# Start API publishing in background
|
|
- name: Start API Publishing
|
|
id: publish-api
|
|
run: |
|
|
echo "Starting API publishing in background..."
|
|
(
|
|
./gradlew -Dorg.gradle.jvmargs="${{ env.GRAALVM_ARGS }} ${{ env.GRADLE_MEMORY }}" publish --parallel --max-workers=4 > publish_api_log.txt 2>&1
|
|
# Uncomment when ready to implement:
|
|
# ./gradlew -Dorg.gradle.jvmargs="${{ env.GRAALVM_ARGS }} ${{ env.GRADLE_MEMORY }}" publishDevBundlePublicationToLeafRepository -PpublishDevBundle=true --parallel >> publish_api_log.txt 2>&1
|
|
echo "API_PUBLISH_DONE=true" >> $GITHUB_ENV
|
|
) &
|
|
|
|
# Store the background process ID
|
|
echo "PUBLISH_PID=$!" >> $GITHUB_ENV
|
|
echo "API publishing started in background with PID $!"
|
|
env:
|
|
REPO_USER: ${{ secrets.REPO_USER }}
|
|
REPO_PASSWORD: ${{ secrets.REPO_PASSWORD }}
|
|
|
|
- name: Gradle Cache Prune
|
|
run: |
|
|
if [ -d ~/.gradle/caches ]; then
|
|
echo "Before pruning:"
|
|
du -sh ~/.gradle/caches || echo "Could not determine cache size"
|
|
find ~/.gradle/caches -name "*.jar" -type f -atime +30 -delete || echo "No old JAR files to delete"
|
|
find ~/.gradle/caches -name "*.pom" -type f -atime +30 -delete || echo "No old POM files to delete"
|
|
echo "After pruning:"
|
|
du -sh ~/.gradle/caches || echo "Could not determine cache size"
|
|
else
|
|
echo "Gradle cache directory does not exist yet"
|
|
fi
|
|
|
|
- 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 for release
|
|
continue-on-error: true
|
|
run: |
|
|
chmod +x ./scripts/prepareRelease.sh
|
|
./scripts/prepareRelease.sh
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
GITHUB_REPO: ${{ github.repository }}
|
|
|
|
# Wait for API publishing to complete before releasing
|
|
- name: Wait for API Publishing
|
|
run: |
|
|
echo "Waiting for API publishing to complete..."
|
|
# Check if the process is still running
|
|
if ps -p ${{ env.PUBLISH_PID }} > /dev/null; then
|
|
echo "API publishing is still running with PID ${{ env.PUBLISH_PID }}"
|
|
wait ${{ env.PUBLISH_PID }} || true
|
|
echo "API publishing process has completed."
|
|
else
|
|
echo "API publishing process already completed."
|
|
fi
|
|
|
|
# Check for any errors in the log
|
|
if grep -i "error" publish_api_log.txt; then
|
|
echo "Warnings or errors found in API publishing log:"
|
|
cat publish_api_log.txt
|
|
echo "API publishing completed with warnings or errors, but continuing with release."
|
|
else
|
|
echo "API publishing completed successfully."
|
|
fi
|
|
|
|
- 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
|