PKGBUILD builds from the release tag and ships the udev rule; packaging/release.sh tags, pushes, builds and publishes a release. Keep .gitea-token out of git. Co-Authored-By: Claude Opus 5.5 <[email protected]>
64 lines
2.5 KiB
Bash
Executable File
64 lines
2.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# Usage: packaging/release.sh <version> [--prerelease]
|
|
# Bumps the version, tags v<version>, pushes, builds the pacman package from that tag and
|
|
# publishes a Gitea release with the package and PKGBUILD attached.
|
|
# Token: $GITEA_TOKEN or the file .gitea-token in the repository root.
|
|
set -eu
|
|
|
|
VERSION="${1:?Version angeben, z.B. packaging/release.sh 0.2.0}"
|
|
PRERELEASE=false
|
|
[ "${2:-}" = "--prerelease" ] && PRERELEASE=true
|
|
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT"
|
|
API="https://git.mrblake.cc/api/v1/repos/MrBlake/CosairRGBforCachy"
|
|
TOKEN="${GITEA_TOKEN:-$(cat .gitea-token 2>/dev/null || true)}"
|
|
[ -n "$TOKEN" ] || { echo "Kein Token (.gitea-token oder GITEA_TOKEN)"; exit 1; }
|
|
[ -z "$(git status --porcelain)" ] || { echo "Arbeitsverzeichnis nicht sauber"; exit 1; }
|
|
[ "$(git branch --show-current)" = "main" ] || { echo "Nicht auf main"; exit 1; }
|
|
git rev-parse -q --verify "refs/tags/v$VERSION" >/dev/null && { echo "Tag v$VERSION existiert schon"; exit 1; }
|
|
|
|
python3 -m unittest discover -s tests -q
|
|
|
|
PREV_TAG="$(git describe --tags --abbrev=0 2>/dev/null || true)"
|
|
NOTES="$(git log --no-merges --pretty='- %s' ${PREV_TAG:+$PREV_TAG..}HEAD)"
|
|
|
|
sed -i "s/^__version__ = .*/__version__ = \"$VERSION\"/" k65studio/__init__.py
|
|
sed -i "s/^pkgver=.*/pkgver=$VERSION/; s/^pkgrel=.*/pkgrel=1/" packaging/PKGBUILD
|
|
git diff --quiet || git commit -qam "Release v$VERSION"
|
|
git tag -a "v$VERSION" -m "v$VERSION"
|
|
git push -q origin main "v$VERSION"
|
|
|
|
BUILD="$(mktemp -d)"
|
|
trap 'rm -rf "$BUILD"' EXIT
|
|
cp packaging/PKGBUILD packaging/k65studio.install "$BUILD/"
|
|
(cd "$BUILD" && PKGDEST="$BUILD/out" makepkg -f --nodeps --noconfirm >/dev/null)
|
|
PKG="$(ls "$BUILD"/out/*.pkg.tar.zst)"
|
|
|
|
BODY="$(python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))' <<EOF
|
|
## Installation
|
|
|
|
\`\`\`sh
|
|
sudo pacman -U $(basename "$PKG")
|
|
\`\`\`
|
|
|
|
Danach im Startmenü **K65 Studio** öffnen. Die udev-Regel wird mitinstalliert.
|
|
|
|
## Änderungen
|
|
|
|
$NOTES
|
|
EOF
|
|
)"
|
|
|
|
RELEASE_ID="$(curl -sf -X POST "$API/releases" \
|
|
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"v$VERSION\", \"name\": \"K65 Studio $VERSION\", \"body\": $BODY, \"prerelease\": $PRERELEASE}" \
|
|
| python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])')"
|
|
|
|
for f in "$PKG" packaging/PKGBUILD; do
|
|
curl -sf -X POST "$API/releases/$RELEASE_ID/assets?name=$(basename "$f")" \
|
|
-H "Authorization: token $TOKEN" -F "attachment=@$f" >/dev/null
|
|
done
|
|
|
|
echo "Release v$VERSION veröffentlicht: https://git.mrblake.cc/MrBlake/CosairRGBforCachy/releases/tag/v$VERSION"
|