9
0
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:
Dreeam
2025-03-07 08:44:26 -05:00
committed by GitHub
parent 79e012073d
commit f77ea9f730
3 changed files with 120 additions and 33 deletions

View File

@@ -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,7 +18,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@main
with:
fetch-depth: 50
fetch-depth: 0
- name: Setup Gradle Cache
uses: useblacksmith/cache@v5
@@ -48,7 +47,6 @@ jobs:
with:
java-version: 21
github-token: "${{ secrets.GITHUB_TOKEN }}"
set-java-home: true
- name: Grant execute permission for gradlew
run: chmod +x gradlew
@@ -98,10 +96,6 @@ jobs:
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,6 +105,9 @@ 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: |
@@ -136,8 +133,14 @@ jobs:
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
@@ -162,12 +165,12 @@ jobs:
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

View File

@@ -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
View 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"