feat(build): support dynamic appVersion in gradle and remove obsolete release.sh
Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
parent
57b5ede338
commit
236ef048b5
2 changed files with 1 additions and 93 deletions
|
|
@ -34,7 +34,7 @@ kotlin {
|
|||
}
|
||||
}
|
||||
|
||||
val appVersion = "1.0.0"
|
||||
val appVersion = (project.findProperty("appVersion") as? String)?.takeIf { it.isNotBlank() } ?: "1.0.0"
|
||||
|
||||
val generatedSrcDir = layout.buildDirectory.dir("generated/src/jvmMain/kotlin")
|
||||
|
||||
|
|
|
|||
92
release.sh
92
release.sh
|
|
@ -1,92 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# ── Read version from build.gradle.kts ──────────────────────────────────────
|
||||
VERSION=$(sed -n 's/^val appVersion = "\(.*\)"/\1/p' 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