9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2026-01-06 15:41:52 +00:00

use atlas for version uploading

This commit is contained in:
NONPLAYT
2025-12-09 20:21:34 +03:00
parent 1509419aa6
commit 4bb232ca47
4 changed files with 112 additions and 119 deletions

View File

@@ -1,62 +0,0 @@
#!/usr/bin/env bash
sha256() {
sha256sum "$1" | awk '{print $1}'
}
sha1() {
sha1sum "$1" | awk '{print $1}'
}
md5() {
md5sum "$1" | awk '{print $1}'
}
prop() {
grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//'
}
commitid=$(git log --pretty='%h' -1)
mcversion=$(prop mcVersion)
version=$(prop version)
experimental=$(prop experimental)
tagid="$mcversion-$BUILD_NUMBER-$commitid"
jarName="divinemc-$mcversion-$BUILD_NUMBER.jar"
divinemcid="DivineMC-$tagid"
changelog="changelog.md"
make_latest=$([ "$experimental" = "true" ] && echo "false" || echo "true")
rm -f $changelog
mv divinemc-server/build/libs/divinemc-paperclip-"$version"-mojmap.jar "$jarName"
{
echo "name=$divinemcid"
echo "tag=$tagid"
echo "jar=$jarName"
echo "info=$changelog"
echo "experimental=$experimental"
echo "make_latest=$make_latest"
} >> "$GITHUB_ENV"
{
echo "### 📜 Commits"
if [ "$experimental" = "true" ]; then
echo "> [!WARNING]"
echo "> This is an experimental build, it may contain bugs and issues. Use at your own risk."
echo "> **Backups are mandatory!**"
echo ""
fi
} >> $changelog
number=$(git log --oneline ver/1.21.10 ^"$(git describe --tags --abbrev=0)" | wc -l)
git log --pretty='- [`%h`](https://github.com/BX-Team/DivineMC/commit/%H) %s' "-$number" >> $changelog
{
echo ""
echo "### 🔒 Checksums"
echo "| File | $jarName |"
echo "| ---- | ---- |"
echo "| MD5 | $(md5 "$jarName") |"
echo "| SHA1 | $(sha1 "$jarName") |"
echo "| SHA256 | $(sha256 "$jarName") |"
} >> $changelog

67
scripts/uploadBuild.sh Normal file
View File

@@ -0,0 +1,67 @@
#!/bin/bash
set -e
prop() {
grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//'
}
[ -z "$API_URL" ] && { echo "Error: API_URL not set"; exit 1; }
[ -z "$API_KEY" ] && { echo "Error: API_KEY not set"; exit 1; }
[ -z "$PROJECT_KEY" ] && { echo "Error: PROJECT_KEY not set"; exit 1; }
MC_VERSION=$(prop mcVersion)
[ -z "$MC_VERSION" ] && { echo "Error: mcVersion not found in gradle.properties"; exit 1; }
VERSION_BRANCH=${VERSION_BRANCH:-"ver/$MC_VERSION"}
if [ "$(prop experimental)" = "true" ]; then
CHANNEL="BETA"
else
CHANNEL="STABLE"
fi
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
COMMIT_COUNT=$(git log --oneline "$VERSION_BRANCH" ^"$LAST_TAG" 2>/dev/null | wc -l | tr -d ' ')
else
COMMIT_COUNT=$(git log --oneline "$VERSION_BRANCH" 2>/dev/null | wc -l | tr -d ' ')
fi
if [ "$COMMIT_COUNT" -gt 0 ]; then
COMMITS_JSON=$(git log --pretty='{"sha":"%H","message":"%s","time":"%cI"}' "$VERSION_BRANCH" -"$COMMIT_COUNT" | \
sed ':a;N;$!ba;s/\n/,/g' | \
sed 's/"/\\"/g' | \
sed 's/\\\\"/\\"/g')
COMMITS_JSON="[$COMMITS_JSON]"
else
COMMITS_JSON="[]"
fi
METADATA=$(cat <<EOF
{
"channel": "$CHANNEL",
"commits": $COMMITS_JSON
}
EOF
)
echo "Uploading: $PROJECT_KEY $MC_VERSION ($CHANNEL)"
UPLOAD_RESPONSE=$(curl -s -w "\n%{http_code}" \
-X POST "$API_URL/v2/projects/$PROJECT_KEY/versions/$MC_VERSION/builds/upload" \
-H "x-api-key: $API_KEY" \
-F "file=@$JAR_FILE" \
-F "metadata=$METADATA")
HTTP_BODY=$(echo "$UPLOAD_RESPONSE" | head -n -1)
HTTP_CODE=$(echo "$UPLOAD_RESPONSE" | tail -n 1)
if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 201 ]; then
BUILD_ID=$(echo "$HTTP_BODY" | grep -o '"id":[0-9]*' | grep -o '[0-9]*')
echo "✓ Build #$BUILD_ID uploaded successfully"
exit 0
else
echo "✗ Upload failed (HTTP $HTTP_CODE)"
echo "$HTTP_BODY"
exit 1
fi