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

Add API v2

This commit is contained in:
violetc
2023-08-02 11:00:38 +08:00
parent 60e890e4cd
commit 3da663ecc6
2 changed files with 6 additions and 0 deletions

View File

@@ -76,5 +76,6 @@ jobs:
if: "!contains(github.event.commits[0].message, '[release-skip]')" if: "!contains(github.event.commits[0].message, '[release-skip]')"
env: env:
secret: ${{ secrets.API_PUSH_TOKEN }} secret: ${{ secrets.API_PUSH_TOKEN }}
secret_v2: ${{ secrets.API_V2_PUSH_TOKEN }}
tag: ${{ env.tag }} tag: ${{ env.tag }}
run: sh scripts/PushToAPI.sh run: sh scripts/PushToAPI.sh

View File

@@ -23,4 +23,9 @@ changes=$(git log --pretty='%H<<<%s>>>' -"$number" | sed ':a;N;$!ba;s/\n//g')
jar_name="leaves-$mcversion.jar" jar_name="leaves-$mcversion.jar"
jar_sha256=`sha256 $jar_name` jar_sha256=`sha256 $jar_name`
# v1
curl --location --request POST "https://api.leavesmc.top/new_release" --header "Content-Type: application/json" --data-raw "{\"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\"}" curl --location --request POST "https://api.leavesmc.top/new_release" --header "Content-Type: application/json" --data-raw "{\"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\"}"
curl --location --request POST "https://api.leavesmc.top/upload_file" -F "file=@$jar_name" -F "filename=$jar_name" -F "filehash=$jar_sha256" -F "secret=$secret"
# v2
curl --location --request POST "https://api.leavesmc.top/v2/commit/build" --header "Content-Type: application/json" --header "Authentication: Bearer $secret_v2" --data-raw "{\"project_id\":\"$project_id\",\"version\":\"$mcversion\",\"channel\":\"$channel\",\"changes\":\"$changes\",\"jar_name\":\"$jar_name\",\"sha256\":\"$jar_sha256\",\"tag\":\"$tag\"}"