mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
149 lines
5.7 KiB
YAML
149 lines
5.7 KiB
YAML
name: Build Leaf 1.21.5
|
|
|
|
on:
|
|
push:
|
|
branches: [ "dev/1.21.5" ]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: blacksmith-8vcpu-ubuntu-2204
|
|
env:
|
|
BUILD_NUMBER: ${{ github.run_number }}
|
|
GRADLE_MEMORY: "-Xmx4g -XX:MaxMetaspaceSize=2g"
|
|
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', '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: 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.caching=true" >> ~/.gradle/gradle.properties
|
|
echo "org.gradle.configuration-cache=true" >> ~/.gradle/gradle.properties
|
|
echo "org.gradle.configuration-cache.problems=warn" >> ~/.gradle/gradle.properties
|
|
echo "org.gradle.jvmargs=${{ env.GRADLE_MEMORY }} -Dfile.encoding=UTF-8" >> ~/.gradle/gradle.properties
|
|
echo "org.gradle.parallel=true" >> ~/.gradle/gradle.properties
|
|
echo "org.gradle.daemon=true" >> ~/.gradle/gradle.properties
|
|
# This is only need if we create custom gradle.properies in home directory
|
|
echo "leafUsername=${{ secrets.REPO_USER }}" >> ~/.gradle/gradle.properties
|
|
echo "leafPassword=${{ secrets.REPO_PASSWORD }}" >> ~/.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 \
|
|
--no-daemon
|
|
|
|
- name: Create MojmapPaperclipJar
|
|
run: ./gradlew createMojmapPaperclipJar --stacktrace --parallel --no-daemon
|
|
|
|
- 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: Upload Leaf
|
|
uses: actions/upload-artifact@main
|
|
with:
|
|
name: Leaf 1.21.5
|
|
path: ./leaf-1.21.5-${{ env.BUILD_NUMBER }}.jar
|
|
|
|
- name: Release Leaf
|
|
uses: softprops/action-gh-release@v2.2.2 # Temp fix
|
|
with:
|
|
name: "Leaf 1.21.5"
|
|
tag_name: "ver-1.21.5"
|
|
files: "./leaf-1.21.5-${{ env.BUILD_NUMBER }}.jar"
|
|
body_path: "./release_notes.md"
|
|
token: "${{ secrets.GITHUB_TOKEN }}"
|
|
target_commitish: "${{ github.sha }}"
|
|
draft: false
|
|
prerelease: true
|
|
|
|
- name: Calculate SHA-256
|
|
id: hash
|
|
run: |
|
|
FILE_NAME="leaf-1.21.5-${{ env.BUILD_NUMBER }}.jar"
|
|
HASH=$(sha256sum "$FILE_NAME" | awk '{ print $1 }')
|
|
echo "sha256=$HASH" >> $GITHUB_OUTPUT
|
|
- name: Upload JAR to download API
|
|
uses: appleboy/scp-action@master
|
|
with:
|
|
host: ${{ secrets.API_HOST }}
|
|
username: ${{ secrets.API_USER }}
|
|
password: ${{ secrets.API_PASS }}
|
|
source: "./leaf-1.21.5-${{ env.BUILD_NUMBER }}.jar"
|
|
target: "~/api/uploads/"
|
|
|
|
- name: Insert build to download API
|
|
uses: appleboy/ssh-action@master
|
|
with:
|
|
host: ${{ secrets.API_HOST }}
|
|
username: ${{ secrets.API_USER }}
|
|
password: ${{ secrets.API_PASS }}
|
|
script: |
|
|
BRANCH="${{ github.ref_name }}"
|
|
REPO_DIR="/root/Leaf-${BRANCH//\//-}" # Replace slashes with dashes to avoid directory issues
|
|
[ -d "$REPO_DIR/.git" ] && cd "$REPO_DIR" && git fetch origin && git checkout "$BRANCH" && git reset --hard "origin/$BRANCH" || git clone --branch "$BRANCH" --depth 1 https://github.com/Winds-Studio/Leaf "$REPO_DIR"
|
|
# Proceed to insert the build into the API
|
|
cd ~/api/cli
|
|
node insertBuild.js \
|
|
--projectName leaf \
|
|
--projectFriendlyName "Leaf" \
|
|
--version 1.21.5 \
|
|
--versionGroupName 1.21.5 \
|
|
--versionName 1.21.5 \
|
|
--build-number ${{ env.BUILD_NUMBER }} \
|
|
--repositoryPath "$REPO_DIR" \
|
|
--storagePath /root/api/storage \
|
|
--download "primary:/root/api/uploads/leaf-1.21.5-${{ env.BUILD_NUMBER }}.jar:${{ steps.hash.outputs.sha256 }}" \
|
|
--buildChannel default
|