9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00

[release-skip] Add support for api.leavesmc.top (#75)

* Update leaves.yml
This commit is contained in:
z0z0r4
2023-07-29 16:22:20 +08:00
committed by GitHub
parent 4de2295de4
commit cec1d2903d
2 changed files with 53 additions and 0 deletions

View File

@@ -72,3 +72,9 @@ jobs:
with:
name: ${{ env.jar }}
path: ${{ env.jar }}
- name: Push to Api
if: "!contains(github.event.commits[0].message, '[release-skip]')"
env:
secret: ${{ secrets.API_PUSH_TOKEN }}
tag: ${{ env.tag }}
run: sh scripts/push_to_api.sh

47
scripts/PushToAPI.sh Normal file
View File

@@ -0,0 +1,47 @@
sha256() {
sha256sum $1 | awk '{print $1}'
}
prop() {
grep "${1}" gradle.properties | cut -d'=' -f2 | sed 's/\r//'
}
echo "$tag"
project_id="leaves"
project_name="leaves"
mcversion=$(prop mcVersion)
ctime=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
pre=$(prop preVersion)
if [ $pre = "true" ]; then
channel="experimental"
else
channel="default"
fi
promoted=false
number=$(git log --oneline master ^`git describe --tags --abbrev=0` | wc -l)
changes=$(echo "(git log --pretty='%H<<<%s>>>' -number)" | sed 's/\\n/\\\\n/g')
jar_name="leaves-$mcversion.jar"
jar_sha256=`sha256 $jar_name`
data=$(cat <<EOF
{
"project_id": "$project_id",
"project_name": "$project_name",
"version": "$mcversion",
"time": "$ctime",
"channel": "$channel",
"promoted": $promoted,
"changes": "$changes",
"downloads": {
"application": {
"name": "$jar_name",
"sha256": "$jar_sha256",
"url": "https://github.com/LeavesMC/Leaves/releases/download/$tag/$jar_name"
}
},
"secret": "$secret"
}
EOF
)
curl -X POST -H "Content-Type: application/json" -d "$data" https://api.leavesmc.top/new_release