Use Gitea release asset upload API
This commit is contained in:
@@ -37,6 +37,7 @@ jobs:
|
||||
shell: bash
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
@@ -44,15 +45,21 @@ jobs:
|
||||
api="${GITHUB_SERVER_URL}/api/v1"
|
||||
release_name="WorldHandler ${tag}"
|
||||
jar="$(find build/libs -maxdepth 1 -name '*neoforge*.jar' -print -quit)"
|
||||
token="${GITEA_TOKEN:-${GITHUB_TOKEN:-}}"
|
||||
|
||||
if [ -z "${jar}" ]; then
|
||||
echo "No NeoForge jar found in build/libs" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${token}" ]; then
|
||||
echo "No Gitea token available" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
release_json="$(mktemp)"
|
||||
if ! curl -fsS \
|
||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-H "Authorization: token ${token}" \
|
||||
-H "Accept: application/json" \
|
||||
"${api}/repos/${GITHUB_REPOSITORY}/releases/tags/${tag}" \
|
||||
-o "${release_json}"; then
|
||||
@@ -60,7 +67,7 @@ jobs:
|
||||
python3 -c 'import json, os; print(json.dumps({"tag_name": os.environ["tag"], "target_commitish": os.environ["GITHUB_SHA"], "name": os.environ["release_name"], "body": "NeoForge 21.1.225 build for Minecraft 1.21.1.", "draft": False, "prerelease": False}))' > "${release_json}"
|
||||
curl -fsS \
|
||||
-X POST \
|
||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-H "Authorization: token ${token}" \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data-binary @"${release_json}" \
|
||||
@@ -77,16 +84,15 @@ jobs:
|
||||
[ -z "${asset_id}" ] && continue
|
||||
curl -fsS \
|
||||
-X DELETE \
|
||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-H "Authorization: token ${token}" \
|
||||
"${api}/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets/${asset_id}"
|
||||
done < assets-to-delete.txt
|
||||
|
||||
curl -fsS \
|
||||
-X POST \
|
||||
-H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-H "Authorization: token ${token}" \
|
||||
-H "Accept: application/json" \
|
||||
-H "Content-Type: application/java-archive" \
|
||||
--data-binary @"${jar}" \
|
||||
-F "attachment=@${jar};type=application/java-archive" \
|
||||
"${api}/repos/${GITHUB_REPOSITORY}/releases/${release_id}/assets?name=${asset_name}"
|
||||
|
||||
- name: Publish jar to artifacts branch
|
||||
|
||||
Reference in New Issue
Block a user