Merge pull request 'Release workflow: upload through Gitea's internal address; add manual trigger' (#13) from release-upload-internal-url into master
Reviewed-on: #13
This commit was merged in pull request #13.
This commit is contained in:
@@ -4,13 +4,27 @@ name: Release
|
||||
# to it. mod_version in gradle.properties is the source of truth: the release
|
||||
# tag must match it (a leading "v" is allowed), so bump mod_version in a PR
|
||||
# before tagging the release.
|
||||
#
|
||||
# To (re)attach jars to an existing release, run this workflow manually with
|
||||
# the release's tag.
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: Tag of the existing release to build and attach jars to
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
TAG: ${{ github.event.release.tag_name || inputs.tag }}
|
||||
# Gitea's internal address. Uploads bypass the Cloudflare tunnel, which
|
||||
# rejects request bodies as large as the mod jars (413).
|
||||
GITEA_API: http://gitea:3000/api/v1
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -18,11 +32,10 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ env.TAG }}
|
||||
submodules: true
|
||||
|
||||
- name: Check tag matches mod_version
|
||||
env:
|
||||
TAG: ${{ github.event.release.tag_name }}
|
||||
run: |
|
||||
MOD_VERSION="$(sed -n 's/^mod_version=//p' gradle.properties | tr -d '[:space:]')"
|
||||
if [ "${TAG#v}" != "$MOD_VERSION" ]; then
|
||||
@@ -47,7 +60,7 @@ jobs:
|
||||
- name: Upload jars to the release
|
||||
env:
|
||||
TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
ASSETS_URL: ${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets
|
||||
REPO: ${{ github.repository }}
|
||||
run: |
|
||||
shopt -s nullglob
|
||||
jars=(build/allJars/*.jar)
|
||||
@@ -56,11 +69,20 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Look the release up by tag so manual runs work too.
|
||||
RELEASE_ID="$(curl --fail-with-body -sS -H "Authorization: token $TOKEN" \
|
||||
"$GITEA_API/repos/$REPO/releases/tags/$TAG" \
|
||||
| grep -o '"id":[0-9]*' | head -n1 | cut -d: -f2)"
|
||||
if [ -z "$RELEASE_ID" ]; then
|
||||
echo "No release found for tag $TAG" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for jar in "${jars[@]}"; do
|
||||
echo "Uploading $(basename "$jar")"
|
||||
echo "Uploading $(basename "$jar") to release $TAG ($RELEASE_ID)"
|
||||
curl --fail-with-body -sS -X POST \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-F "attachment=@$jar" \
|
||||
"$ASSETS_URL"
|
||||
"$GITEA_API/repos/$REPO/releases/$RELEASE_ID/assets"
|
||||
echo
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user