mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Cleanup workflow & Refactor Leaf release to replace deprecated one (#244)
* [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
This commit is contained in:
65
.github/workflows/build-1214.yml
vendored
65
.github/workflows/build-1214.yml
vendored
@@ -10,7 +10,6 @@ jobs:
|
||||
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_OPTS: "-Dorg.gradle.parallel=true -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.incremental=true"
|
||||
GRADLE_MEMORY: "-Xmx4g -XX:MaxMetaspaceSize=2g"
|
||||
PATCH_PARALLELISM: "16"
|
||||
outputs:
|
||||
@@ -19,8 +18,8 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@main
|
||||
with:
|
||||
fetch-depth: 50
|
||||
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Gradle Cache
|
||||
uses: useblacksmith/cache@v5
|
||||
with:
|
||||
@@ -35,24 +34,23 @@ jobs:
|
||||
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 }}"
|
||||
set-java-home: true
|
||||
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config --global user.email "no-reply@github.com"
|
||||
@@ -61,7 +59,7 @@ jobs:
|
||||
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
|
||||
@@ -72,7 +70,7 @@ jobs:
|
||||
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
|
||||
@@ -85,23 +83,19 @@ jobs:
|
||||
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..."
|
||||
(
|
||||
echo "REPO_USER=${{ secrets.REPO_USER }}" >> $GITHUB_ENV
|
||||
export REPO_USER=${{ secrets.REPO_USER }}
|
||||
echo "REPO_PASSWORD=${{ secrets.REPO_PASSWORD }}" >> $GITHUB_ENV
|
||||
export REPO_PASSWORD=${{ secrets.REPO_PASSWORD }}
|
||||
./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
|
||||
@@ -111,7 +105,10 @@ jobs:
|
||||
# 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
|
||||
@@ -124,21 +121,27 @@ jobs:
|
||||
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 jar for release
|
||||
run: mv ./leaf-1.21.4-${{ env.BUILD_NUMBER }}-mojmap.jar ./leaf-1.21.4-${{ env.BUILD_NUMBER }}.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: |
|
||||
@@ -160,14 +163,14 @@ jobs:
|
||||
else
|
||||
echo "API publishing completed successfully."
|
||||
fi
|
||||
|
||||
|
||||
- name: Release Leaf
|
||||
# TODO: Replace with a maintained action as marvinpinto/action-automatic-releases is archived
|
||||
# Recommended alternatives: softprops/action-gh-release or ncipollo/release-action
|
||||
uses: marvinpinto/action-automatic-releases@master
|
||||
uses: softprops/action-gh-release@master
|
||||
with:
|
||||
title: "Leaf 1.21.4"
|
||||
automatic_release_tag: "ver-1.21.4"
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
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
|
||||
|
||||
@@ -55,8 +55,8 @@ subprojects {
|
||||
maven(leafMavenPublicUrl) {
|
||||
name = "leaf"
|
||||
|
||||
credentials.username = "dreeam"
|
||||
credentials.password = "dreeam123"
|
||||
credentials.username = System.getenv("REPO_USER")
|
||||
credentials.password = System.getenv("REPO_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
84
scripts/prepareRelease.sh
Executable file
84
scripts/prepareRelease.sh
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
IS_EOL=false
|
||||
IS_UNSUPPORTED=false
|
||||
|
||||
RELEASE_NOTES="release_notes.md"
|
||||
|
||||
# Rename Leaf jar
|
||||
mv ./leaf-1.21.4-"${BUILD_NUMBER}"-mojmap.jar ./leaf-1.21.4-"${BUILD_NUMBER}".jar
|
||||
|
||||
# Branch name
|
||||
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
echo "✨Current branch: $CURRENT_BRANCH"
|
||||
|
||||
# Latest tag name
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0)
|
||||
if [ -z "$LATEST_TAG" ]; then
|
||||
echo "⚠️No previous release found. Using initial commit."
|
||||
LATEST_TAG=$(git rev-list --max-parents=0 HEAD)
|
||||
fi
|
||||
echo "✨Latest tag: $LATEST_TAG"
|
||||
|
||||
# Commit of the latest tag
|
||||
LAST_RELEASE_COMMIT=$(git rev-list -n 1 "$LATEST_TAG")
|
||||
echo "✨Last release commit: $LAST_RELEASE_COMMIT"
|
||||
|
||||
# Commits log
|
||||
COMMIT_LOG=$(git log "$LAST_RELEASE_COMMIT"..HEAD --pretty=format:"- [\`%h\`](https://github.com/"${GITHUB_REPO}"/commit/%H) %s (%an)")
|
||||
if [ -z "$COMMIT_LOG" ]; then
|
||||
COMMIT_LOG="⚠️No new commits since $LATEST_TAG."
|
||||
fi
|
||||
echo "✅Commits log generated"
|
||||
|
||||
# Release notes header
|
||||
echo "" >> $RELEASE_NOTES
|
||||
|
||||
# Commits log
|
||||
echo "### 📜 Commits:" >> $RELEASE_NOTES
|
||||
echo "***" >> $RELEASE_NOTES
|
||||
echo "" >> $RELEASE_NOTES
|
||||
echo "$COMMIT_LOG" >> $RELEASE_NOTES
|
||||
echo "" >> $RELEASE_NOTES
|
||||
echo "### 🔒 Checksums" >> $RELEASE_NOTES
|
||||
|
||||
# Get checksums
|
||||
ARTIFACTS_DIR="."
|
||||
if [ -d "$ARTIFACTS_DIR" ]; then
|
||||
for file in "$ARTIFACTS_DIR"/*.jar; do
|
||||
if [ -f "$file" ]; then
|
||||
MD5=$(md5sum "$file" | awk '{ print $1 }')
|
||||
SHA256=$(sha256sum "$file" | awk '{ print $1 }')
|
||||
FILENAME=$(basename "$file")
|
||||
|
||||
echo "| | $FILENAME |" >> $RELEASE_NOTES
|
||||
echo "| --------- | --------- |" >> $RELEASE_NOTES
|
||||
echo "| MD5 | $MD5 |" >> $RELEASE_NOTES
|
||||
echo "| SHA256 | $SHA256 |" >> $RELEASE_NOTES
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "⚠️No artifacts found." >> $RELEASE_NOTES
|
||||
fi
|
||||
echo "🔒Checksums calculated"
|
||||
|
||||
# EOL warning
|
||||
if [ "$IS_EOL" = true ]; then
|
||||
echo "" >> $RELEASE_NOTES
|
||||
echo "> [!WARNING]" >> $RELEASE_NOTES
|
||||
echo "> This version of Leaf is end-of-life and will only receive critical bugfixes from upstream." >> $RELEASE_NOTES
|
||||
echo "> Update to latest version and gain better performance!" >> $RELEASE_NOTES
|
||||
fi
|
||||
|
||||
# Unsupported warning
|
||||
if [ "$IS_UNSUPPORTED" = true ]; then
|
||||
echo "" >> $RELEASE_NOTES
|
||||
echo "> [!CAUTION]" >> $RELEASE_NOTES
|
||||
echo "> This version of Leaf is unsupported and will not receive any bugfixes." >> $RELEASE_NOTES
|
||||
echo "> Use at your own risk!" >> $RELEASE_NOTES
|
||||
fi
|
||||
|
||||
# Delete last tag
|
||||
gh release delete ver-1.21.4 --cleanup-tag -y -R "${GITHUB_REPO}"
|
||||
echo "🚀Ready for release"
|
||||
Reference in New Issue
Block a user