Split release publishing into a separate public distribution repo
Gitea has no per-release visibility override -- a repo is public or private for everything (raw files, releases, API), confirmed against Gitea's own docs/issue tracker. So manifest.json and release zips now publish to a dedicated public repo (JellyfinSyncPlus-repo) via Gitea's Contents API, while this source repo stays private. The v0.2.0.0 release already pushed under the old (source-repo-only) version of this pipeline is now stale; the next tag will publish correctly under the new split. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
# Fetches the current manifest.json from the public distribution repo (or starts fresh
|
||||
# if this is the first release), merges in this build's version entry, and pushes it
|
||||
# back -- all via Gitea's Contents API, so this never needs a git clone of the public
|
||||
# repo. Keeps the private source repo and the public distribution repo fully decoupled.
|
||||
#
|
||||
# Required env vars:
|
||||
# GITEA_TOKEN, SERVER_URL, PUBLIC_REPO_OWNER, PUBLIC_REPO_NAME, VERSION, CHECKSUM, SOURCE_URL
|
||||
set -euo pipefail
|
||||
|
||||
: "${GITEA_TOKEN:?}"
|
||||
: "${SERVER_URL:?}"
|
||||
: "${PUBLIC_REPO_OWNER:?}"
|
||||
: "${PUBLIC_REPO_NAME:?}"
|
||||
: "${VERSION:?}"
|
||||
: "${CHECKSUM:?}"
|
||||
: "${SOURCE_URL:?}"
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
API="${SERVER_URL}/api/v1/repos/${PUBLIC_REPO_OWNER}/${PUBLIC_REPO_NAME}/contents/manifest.json"
|
||||
WORKDIR=$(mktemp -d)
|
||||
trap 'rm -rf "$WORKDIR"' EXIT
|
||||
|
||||
HTTP_CODE=$(curl -s -o "$WORKDIR/existing.json" -w "%{http_code}" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" "${API}?ref=master")
|
||||
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
SHA=$(python3 -c 'import json; print(json.load(open("'"$WORKDIR"'/existing.json"))["sha"])')
|
||||
python3 -c 'import json,base64
|
||||
d = json.load(open("'"$WORKDIR"'/existing.json"))
|
||||
open("'"$WORKDIR"'/manifest.json", "wb").write(base64.b64decode(d["content"]))'
|
||||
echo "Fetched existing manifest.json (sha ${SHA})"
|
||||
else
|
||||
SHA=""
|
||||
echo "[]" > "$WORKDIR/manifest.json"
|
||||
echo "No existing manifest.json in ${PUBLIC_REPO_OWNER}/${PUBLIC_REPO_NAME} -- starting fresh (HTTP $HTTP_CODE)"
|
||||
fi
|
||||
|
||||
python3 "$ROOT/dev/update_manifest.py" \
|
||||
--build-yaml "$ROOT/build.yaml" \
|
||||
--manifest "$WORKDIR/manifest.json" \
|
||||
--version "$VERSION" \
|
||||
--checksum "$CHECKSUM" \
|
||||
--source-url "$SOURCE_URL"
|
||||
|
||||
CONTENT_B64=$(base64 -w0 "$WORKDIR/manifest.json")
|
||||
|
||||
python3 -c 'import json,sys
|
||||
body = {"content": sys.argv[1], "message": "Release " + sys.argv[2], "branch": "master"}
|
||||
if sys.argv[3]:
|
||||
body["sha"] = sys.argv[3]
|
||||
json.dump(body, open(sys.argv[4], "w"))' "$CONTENT_B64" "$VERSION" "$SHA" "$WORKDIR/body.json"
|
||||
|
||||
METHOD="POST"
|
||||
if [ -n "$SHA" ]; then
|
||||
METHOD="PUT"
|
||||
fi
|
||||
|
||||
curl -sf -X "$METHOD" \
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "@$WORKDIR/body.json" \
|
||||
"$API" > /dev/null
|
||||
|
||||
echo "Published manifest.json version ${VERSION} to ${PUBLIC_REPO_OWNER}/${PUBLIC_REPO_NAME}"
|
||||
Reference in New Issue
Block a user