#!/bin/sh # Usage: packaging/release.sh [--prerelease] # Bumps the version, tags v, 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" AUTH="$(printf 'MrBlake:%s' "$TOKEN" | base64 -w0)" git -c http.extraHeader="Authorization: Basic $AUTH" 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()))' </dev/null done echo "Release v$VERSION veröffentlicht: https://git.mrblake.cc/MrBlake/CosairRGBforCachy/releases/tag/v$VERSION"