9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/scripts/prepareRelease.sh
Dreeam f77ea9f730 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
2025-03-07 08:44:26 -05:00

85 lines
2.5 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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"