chore(release): release_gitea.sh (Tag+Release+Assets) hinzugefügt

This commit is contained in:
Markus F.J. Busche
2025-09-21 13:24:40 +02:00
parent 4ffb6f82b9
commit 876048f60e

86
scripts/release_gitea.sh Normal file → Executable file
View File

@@ -1,6 +1,92 @@
#!/usr/bin/env bash
set -euo pipefail
# Usage: scripts/release_gitea.sh <version> [--draft] [--prerelease]
# Requires: GITEA_TOKEN, GITEA_BASE (e.g. https://gitea.elpatron.me), OWNER (e.g. elpatron), REPO (e.g. octo-funnel)
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <version> [--draft] [--prerelease]" >&2
exit 1
fi
VERSION="$1"
shift || true
DRAFT=false
PRERELEASE=false
for arg in "$@"; do
case "$arg" in
--draft) DRAFT=true ;;
--prerelease) PRERELEASE=true ;;
esac
done
: "${GITEA_TOKEN:?Set GITEA_TOKEN}"
: "${GITEA_BASE:?Set GITEA_BASE (e.g. https://gitea.elpatron.me)}"
: "${OWNER:?Set OWNER (e.g. elpatron)}"
: "${REPO:?Set REPO (e.g. octo-funnel)}"
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
DIST_DIR="$ROOT_DIR/octoprint_tailscale_funnel/dist"
TAG="v${VERSION}"
echo "Creating git tag ${TAG} and pushing..."
git tag -f "${TAG}"
git push -f origin "${TAG}"
echo "Creating Gitea release ${TAG}..."
BODY=$(cat <<EOF
Release ${TAG}
Changes:
- Navbar: Statusanzeige, Toggle, Farbkennung
- Build-Skript & Quick-Build Docs
- Version ${VERSION}
EOF
)
CREATE_PAYLOAD=$(jq -n \
--arg tag_name "${TAG}" \
--arg name "${TAG}" \
--arg body "${BODY}" \
--argjson draft ${DRAFT} \
--argjson prerelease ${PRERELEASE} \
'{tag_name:$tag_name, name:$name, body:$body, draft:$draft, prerelease:$prerelease}')
RELEASE_JSON=$(curl -sS -X POST "${GITEA_BASE}/api/v1/repos/${OWNER}/${REPO}/releases" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H 'Content-Type: application/json' \
-d "${CREATE_PAYLOAD}")
UPLOAD_URL=$(echo "$RELEASE_JSON" | jq -r .upload_url)
ID=$(echo "$RELEASE_JSON" | jq -r .id)
if [[ -z "$ID" || "$ID" == "null" ]]; then
echo "Failed to create release: $RELEASE_JSON" >&2
exit 1
fi
echo "Release created: ID=$ID"
function upload_asset() {
local file="$1"
local name
name=$(basename "$file")
echo "Uploading asset: $name"
curl -sS -X POST "${GITEA_BASE}/api/v1/repos/${OWNER}/${REPO}/releases/${ID}/assets?name=${name}" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H 'Content-Type: application/octet-stream' \
--data-binary @"$file" > /dev/null
}
upload_asset "$DIST_DIR/octoprint_tailscale_funnel-${VERSION}-py3-none-any.whl"
upload_asset "$DIST_DIR/octoprint_tailscale_funnel-${VERSION}.tar.gz"
upload_asset "$DIST_DIR/octoprint_tailscale_funnel-${VERSION}.zip"
echo "Release ${TAG} created and assets uploaded."
#!/usr/bin/env bash
set -euo pipefail
# Load .env if present
if [ -f "$(dirname "$0")/../.env" ]; then
set -a