mirror of
https://github.com/TommyFang2077/dsh-desktop.git
synced 2026-08-17 09:06:36 +08:00
feat: publish Gitea releases via Gitea Actions runner
This commit is contained in:
50
scripts/publish-gitea-actions.sh
Executable file
50
scripts/publish-gitea-actions.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
# Gitea Actions publisher: download a GitHub release's assets and publish
|
||||
# them to the local Gitea instance over the LAN interface (bypassing the
|
||||
# public reverse proxy, which times out on large uploads).
|
||||
set -euo pipefail
|
||||
|
||||
GITHUB_REPO="${GITHUB_REPO:-TommyFang2077/dsh-easy-desktop}"
|
||||
REPO_OWNER="${GITEA_OWNER:-TomHanck4}"
|
||||
REPO_NAME="${GITEA_REPO:-dsh-easy-desktop}"
|
||||
GITEA_BASE_URL="${GITEA_BASE_URL:-http://192.168.30.33:3000}"
|
||||
PACKAGE_BASE_URL="${PACKAGE_BASE_URL:-https://git.fangsiyuan.top/api/packages/TomHanck4/generic/dsh-easy-desktop-updater}"
|
||||
RELEASE_TAG="${RELEASE_TAG:-latest}"
|
||||
: "${GITEA_TOKEN:?GITEA_TOKEN is required}"
|
||||
|
||||
if [[ "$RELEASE_TAG" == "latest" ]]; then
|
||||
RELEASE_TAG=$(curl -fsS "https://api.github.com/repos/$GITHUB_REPO/releases?per_page=1" | jq -r '.[0].tag_name')
|
||||
fi
|
||||
[[ -n "$RELEASE_TAG" && "$RELEASE_TAG" != "null" ]] || {
|
||||
echo "no GitHub release found" >&2
|
||||
exit 1
|
||||
}
|
||||
VERSION="${RELEASE_TAG#v}"
|
||||
echo "target: $RELEASE_TAG ($VERSION)"
|
||||
echo "gitea: $GITEA_BASE_URL"
|
||||
|
||||
if curl -fsS -H "Authorization: token $GITEA_TOKEN" \
|
||||
"$GITEA_BASE_URL/api/v1/repos/$REPO_OWNER/$REPO_NAME/releases/tags/$RELEASE_TAG" >/dev/null 2>&1; then
|
||||
echo "release $RELEASE_TAG already published on Gitea; nothing to do"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rm -rf artifacts staged
|
||||
mkdir -p artifacts
|
||||
|
||||
curl -fsS "https://api.github.com/repos/$GITHUB_REPO/releases/tags/$RELEASE_TAG" -o /tmp/release.json
|
||||
jq -r '.assets[].browser_download_url' /tmp/release.json | while read -r url; do
|
||||
curl -fsSL --retry 3 --retry-delay 5 -o "artifacts/$(basename "$url")" "$url" &
|
||||
done
|
||||
wait
|
||||
echo "downloaded $(find artifacts -type f | wc -l) assets"
|
||||
|
||||
python3 build-gitea-update.py \
|
||||
--flat-artifacts artifacts \
|
||||
--output staged \
|
||||
--version "$VERSION" \
|
||||
--pub-date "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
--package-base-url "$PACKAGE_BASE_URL"
|
||||
|
||||
bash publish-gitea-release.sh staged
|
||||
echo "published $RELEASE_TAG to Gitea"
|
||||
Reference in New Issue
Block a user