Housekeeping
This commit is contained in:
parent
17ba07deef
commit
ecdbd5cfeb
2 changed files with 93 additions and 1 deletions
|
|
@ -69,7 +69,7 @@ body:
|
||||||
id: app-version
|
id: app-version
|
||||||
attributes:
|
attributes:
|
||||||
label: App version
|
label: App version
|
||||||
description: You can find this in the app's title bar or About screen.
|
description: You can find this in the app's Status screen.
|
||||||
placeholder: "e.g. 1.0.0"
|
placeholder: "e.g. 1.0.0"
|
||||||
|
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
|
|
||||||
92
release.sh
Executable file
92
release.sh
Executable file
|
|
@ -0,0 +1,92 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# ── Read version from build.gradle.kts ──────────────────────────────────────
|
||||||
|
VERSION=$(grep -oP 'val appVersion\s*=\s*"\K[^"]+' composeApp/build.gradle.kts)
|
||||||
|
TAG="v${VERSION}"
|
||||||
|
echo "==> Version: ${VERSION} (tag: ${TAG})"
|
||||||
|
|
||||||
|
# ── Require FORGEJO_TOKEN ────────────────────────────────────────────────────
|
||||||
|
if [[ -z "${FORGEJO_TOKEN:-}" ]]; then
|
||||||
|
echo "ERROR: FORGEJO_TOKEN env var is not set." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── Detect OS and set build task / artifact glob ─────────────────────────────
|
||||||
|
OS="$(uname -s)"
|
||||||
|
case "${OS}" in
|
||||||
|
Darwin)
|
||||||
|
TASK=":composeApp:packageDmg"
|
||||||
|
GLOB="composeApp/build/compose/binaries/main/dmg/*.dmg"
|
||||||
|
;;
|
||||||
|
MINGW*|MSYS*|CYGWIN*|Windows_NT)
|
||||||
|
TASK=":composeApp:packageMsi"
|
||||||
|
GLOB="composeApp/build/compose/binaries/main/msi/*.msi"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "ERROR: Unsupported OS '${OS}'." >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "==> OS detected: ${OS} — task: ${TASK}"
|
||||||
|
|
||||||
|
# ── Build ────────────────────────────────────────────────────────────────────
|
||||||
|
echo "==> Building..."
|
||||||
|
./gradlew ${TASK}
|
||||||
|
|
||||||
|
# ── Locate artifact ──────────────────────────────────────────────────────────
|
||||||
|
ARTIFACT=$(ls ${GLOB} 2>/dev/null | head -1)
|
||||||
|
if [[ -z "${ARTIFACT}" ]]; then
|
||||||
|
echo "ERROR: No artifact found matching ${GLOB}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "==> Artifact: ${ARTIFACT}"
|
||||||
|
|
||||||
|
# ── Forgejo API setup ────────────────────────────────────────────────────────
|
||||||
|
API_BASE="https://git.asarius.site/api/v1"
|
||||||
|
REPO="rukira/wow-backup"
|
||||||
|
|
||||||
|
# ── Check for existing release ───────────────────────────────────────────────
|
||||||
|
echo "==> Checking for existing release ${TAG}..."
|
||||||
|
HTTP_CODE=$(curl -s -o /tmp/release_response.json -w "%{http_code}" \
|
||||||
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases/tags/${TAG}")
|
||||||
|
|
||||||
|
if [[ "${HTTP_CODE}" == "200" ]]; then
|
||||||
|
RELEASE_ID=$(python3 -c "import json; print(json.load(open('/tmp/release_response.json'))['id'])")
|
||||||
|
echo "==> Found existing release (id: ${RELEASE_ID})"
|
||||||
|
else
|
||||||
|
echo "==> Creating release ${TAG}..."
|
||||||
|
HTTP_CODE=$(curl -s -o /tmp/release_create.json -w "%{http_code}" \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${TAG}\", \"body\": \"Release ${TAG}\"}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases")
|
||||||
|
|
||||||
|
if [[ "${HTTP_CODE}" != "201" ]]; then
|
||||||
|
echo "ERROR: Failed to create release (HTTP ${HTTP_CODE}):" >&2
|
||||||
|
cat /tmp/release_create.json >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
RELEASE_ID=$(python3 -c "import json; print(json.load(open('/tmp/release_create.json'))['id'])")
|
||||||
|
echo "==> Created release (id: ${RELEASE_ID})"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ── Upload artifact ──────────────────────────────────────────────────────────
|
||||||
|
FILENAME=$(basename "${ARTIFACT}")
|
||||||
|
echo "==> Uploading ${FILENAME}..."
|
||||||
|
HTTP_CODE=$(curl -s -o /tmp/upload_response.json -w "%{http_code}" \
|
||||||
|
-X POST \
|
||||||
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
|
-F "attachment=@${ARTIFACT}" \
|
||||||
|
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}")
|
||||||
|
|
||||||
|
if [[ "${HTTP_CODE}" != "201" ]]; then
|
||||||
|
echo "ERROR: Failed to upload artifact (HTTP ${HTTP_CODE}):" >&2
|
||||||
|
cat /tmp/upload_response.json >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "==> Done! ${FILENAME} uploaded to release ${TAG}."
|
||||||
Loading…
Add table
Add a link
Reference in a new issue