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