BlueGit

timfa bluegit

Files

bluegit / scripts / publish-aur.sh

publish-aur.sh

fix: gebruik de committer-tijd als AUR-pkgver
timfa project_87923614_bot_3aff574f6f98414b945a8799374f9092 · pushed by timfa · 3 weeks ago
2388e414 History
publish-aur.sh 2.8 KiB Download Raw
1#!/usr/bin/env bash
2# Update the AUR package bluegit from the GitLab source archive of this commit.
3# Pushes ssh://aur@aur.archlinux.org/bluegit.git master. AUR only accepts master.
4set -euo pipefail
5
6ROOT="$(cd "$(dirname "$0")/.." && pwd)"
7# shellcheck source=aur-common.sh
8source "$(dirname "$0")/aur-common.sh"
9
10# pkgver_of_commit is YYYYMMDDHHMMSS in UTC, from the committer time.
11# CI_COMMIT_TIMESTAMP is ISO 8601. Without it, git show -s --format=%cI
12# is the same instant the self-updater uses. The job clock is not a version.
13pkgver_of_commit() {
14 local root="$1"
15 local commit="${2:-}"
16 if [[ -z "$commit" ]]; then
17 commit="$(git -C "$root" rev-parse HEAD)"
18 fi
19 [[ "$commit" =~ ^[0-9a-f]{40}$ ]] || { echo "CI_COMMIT_SHA or HEAD is not a full sha" >&2; return 1; }
20 local stamp version
21 if [[ -n "${CI_COMMIT_TIMESTAMP:-}" ]]; then
22 stamp="$CI_COMMIT_TIMESTAMP"
23 else
24 stamp="$(git -C "$root" show -s --format=%cI "$commit")"
25 fi
26 version="$(date -u -d "$stamp" +%Y%m%d%H%M%S)"
27 [[ "$version" =~ ^[0-9]{14}$ ]] || { echo "pkgver is not a timestamp: ${version:-empty} from ${stamp:-empty}" >&2; return 1; }
28 printf '%s\n' "$version"
29}
30
31if [[ "${1:-}" == "--rewrite-only" ]]; then
32 rewrite_pkgbuild "$2" "$3" "$4" "$5"
33 exit 0
34fi
35
36if [[ "${1:-}" == "--print-pkgver" ]]; then
37 pkgver_of_commit "$ROOT" "${CI_COMMIT_SHA:-}"
38 exit
39fi
40
41for cmd in git sed sha256sum curl; do
42 command -v "$cmd" >/dev/null || { echo "Missing command: $cmd" >&2; exit 1; }
43done
44
45COMMIT="${CI_COMMIT_SHA:-$(git -C "$ROOT" rev-parse HEAD)}"
46VERSION="$(pkgver_of_commit "$ROOT" "$COMMIT")"
47
48TMPDIR="${TMPDIR:-/tmp}"
49WORKDIR="$(mktemp -d "$TMPDIR/bluegit-aur-XXXXXX")"
50cleanup() { rm -rf "$WORKDIR"; }
51trap cleanup EXIT
52
53SOURCE_URL="https://gitlab.com/Timfa/bluegit/-/archive/${COMMIT}/bluegit-${COMMIT}.tar.gz"
54TMP_SOURCE="$WORKDIR/source.tar.gz"
55echo "Checking source tarball: $SOURCE_URL"
56if ! curl -fsSL "$SOURCE_URL" -o "$TMP_SOURCE"; then
57 echo "Could not download $SOURCE_URL" >&2
58 exit 1
59fi
60SOURCE_SHA="$(sha256sum "$TMP_SOURCE" | awk '{print $1}')"
61
62dest="$WORKDIR/bluegit"
63clone_or_init_aur_repo "bluegit" "$dest"
64cd "$dest"
65git config user.name "${AUR_GIT_AUTHOR_NAME:-BlueGit release bot}"
66git config user.email "${AUR_GIT_AUTHOR_EMAIL:-noreply@example.invalid}"
67cp "$ROOT/packaging/aur/PKGBUILD" PKGBUILD
68cp "$ROOT/packaging/aur/bluegit.install" bluegit.install
69rewrite_pkgbuild "$VERSION" "$COMMIT" "$SOURCE_SHA" PKGBUILD
70generate_srcinfo
71
72if git diff --quiet -- PKGBUILD .SRCINFO bluegit.install 2>/dev/null && git rev-parse --verify HEAD >/dev/null 2>&1; then
73 echo "AUR repo already up to date: bluegit ${VERSION}"
74 exit 0
75fi
76
77git add PKGBUILD .SRCINFO bluegit.install
78if git rev-parse --verify HEAD >/dev/null 2>&1; then
79 git commit -m "upstream ${VERSION}"
80else
81 git commit -m "initial import ${VERSION}"
82fi
83git push -u origin master
84echo "AUR updated: bluegit ${VERSION}"