Skip to content

Commit

Permalink
[release-skip] Add support for api.leavesmc.top (#75)
Browse files Browse the repository at this point in the history
* Update leaves.yml
  • Loading branch information
z0z0r4 authored Jul 29, 2023
1 parent 4de2295 commit cec1d29
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/leaves.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 47 additions & 0 deletions scripts/PushToAPI.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cec1d29

Please sign in to comment.