Files
jasp-desktop-bin/scripts/publish-github-release.sh
T
agw 0d4db32d5c
Build JASP binary and publish to AUR / check (push) Successful in 10s
Build JASP binary and publish to AUR / build (push) Failing after 12s
Automated Arch binary builds of JASP for the AUR
Upstream JASP ships no Linux binary, so the existing AUR package builds
everything from source including several hundred R packages. This builds
that once in CI and publishes the result as jasp-desktop-bin.

JASP links against the system R and Qt6 rather than bundling them, so a
rebuild is triggered by an Arch r/qt6-base bump as well as by a new JASP
release, and the generated PKGBUILD pins depends to the versions actually
built against.
2026-09-01 20:30:00 +02:00

64 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# Create (or reuse) a GitHub release and upload the JASP tarball to it.
# Uses the REST API directly so the workflow does not depend on `gh` being
# present in the runner image.
#
# GH_TOKEN PAT with `contents: write` on the target repo (required)
# GH_OWNER GitHub account owning the release repo (required)
# GH_REPO release repo name (default jasp-desktop-bin)
# TAG release tag, e.g. v0.98.1-1 (required)
# ASSET path to the tarball to upload (required)
set -euo pipefail
: "${GH_TOKEN:?GH_TOKEN is required}"
: "${GH_OWNER:?GH_OWNER is required}"
: "${TAG:?TAG is required}"
: "${ASSET:?ASSET is required}"
GH_REPO="${GH_REPO:-jasp-desktop-bin}"
API="https://api.github.com/repos/${GH_OWNER}/${GH_REPO}"
UPLOADS="https://uploads.github.com/repos/${GH_OWNER}/${GH_REPO}"
AUTH=(-H "Authorization: Bearer ${GH_TOKEN}" -H "Accept: application/vnd.github+json")
asset_name="$(basename "$ASSET")"
echo ":: looking for existing release $TAG"
release_id="$(curl -sSf "${AUTH[@]}" "${API}/releases/tags/${TAG}" 2>/dev/null \
| python3 -c 'import json,sys; print(json.load(sys.stdin).get("id",""))' 2>/dev/null || true)"
if [[ -z "$release_id" ]]; then
echo ":: creating release $TAG"
release_id="$(curl -sSf -X POST "${AUTH[@]}" "${API}/releases" \
-d "$(python3 -c '
import json, os
print(json.dumps({
"tag_name": os.environ["TAG"],
"name": "JASP " + os.environ["TAG"],
"body": os.environ.get("RELEASE_NOTES", ""),
"draft": False,
"prerelease": False,
}))')" | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')"
else
echo ":: reusing release $release_id"
# Replace a same-named asset so re-runs are idempotent.
old="$(curl -sSf "${AUTH[@]}" "${API}/releases/${release_id}/assets" \
| python3 -c "
import json, sys
name = '${asset_name}'
print(next((a['id'] for a in json.load(sys.stdin) if a['name'] == name), ''))
")"
if [[ -n "$old" ]]; then
echo ":: deleting previous asset $old"
curl -sSf -X DELETE "${AUTH[@]}" "${API}/releases/assets/${old}"
fi
fi
echo ":: uploading $asset_name ($(du -h "$ASSET" | cut -f1))"
curl -sSf -X POST "${AUTH[@]}" \
-H "Content-Type: application/zstd" \
--data-binary "@${ASSET}" \
"${UPLOADS}/releases/${release_id}/assets?name=${asset_name}" >/dev/null
echo ":: uploaded to https://github.com/${GH_OWNER}/${GH_REPO}/releases/tag/${TAG}"