BlueGit

golden-age paperdoll-renderer

Files

paperdoll-renderer / scripts / ci / publish-aur.sh

publish-aur.sh

publish-aur.sh 2.1 KiB Download Raw
1#!/usr/bin/env bash
2# publish-aur.sh PKGNAME — adapted from timfa/legacy-cycles.
3# Runs in the tag pipeline after `release`: downloads this tag's .deb release
4# asset, sets pkgver/_tag/sha256sums in packaging/aur/PKGNAME/PKGBUILD,
5# regenerates .SRCINFO and pushes to aur.archlinux.org (the first push creates
6# the AUR package). Uses AUR_GIT_AUTHOR_NAME / AUR_GIT_AUTHOR_EMAIL; the SSH
7# key comes from aur-ssh-setup.sh (AUR_SSH_PRIVATE_KEY_B64).
8set -euo pipefail
9pkg="$1"
10ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
11SRC="$ROOT/packaging/aur/$pkg"
12: "${CI_COMMIT_TAG:?}" "${CI_PROJECT_URL:?}" "${AUR_GIT_AUTHOR_NAME:?}" "${AUR_GIT_AUTHOR_EMAIL:?}"
13tag="$CI_COMMIT_TAG"
14[[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "not a release tag: $tag" >&2; exit 1; }
15ver="${tag#v}"
16url="$CI_PROJECT_URL/-/releases/$tag/assets/paperdoll-renderer-${tag}-amd64.deb"
17
18WORKDIR="$(mktemp -d)"; export WORKDIR
19trap 'rm -rf "$WORKDIR"' EXIT
20curl -fsSL "$url" -o "$WORKDIR/asset.deb"
21sha="$(sha256sum "$WORKDIR/asset.deb" | awk '{print $1}')"
22echo "$pkg $ver $url $sha"
23
24dest="$WORKDIR/$pkg"
25remote="ssh://aur@aur.archlinux.org/${pkg}.git"
26if ! git clone "$remote" "$dest"; then
27 echo "AUR repo $pkg does not exist yet; the first push creates it"
28 mkdir -p "$dest"; git -C "$dest" init -q -b master; git -C "$dest" remote add origin "$remote"
29fi
30git -C "$dest" symbolic-ref HEAD refs/heads/master
31find "$dest" -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
32cp -a "$SRC/." "$dest/"
33cd "$dest"
34sed -i "s/^pkgver=.*/pkgver=${ver}/; s/^pkgrel=.*/pkgrel=1/; s/^_tag=.*/_tag=${tag}/; s/^sha256sums=.*/sha256sums=('${sha}')/" PKGBUILD
35
36useradd -m aurbuild 2>/dev/null || true
37chmod 755 "$WORKDIR"; chown -R aurbuild "$dest"
38runuser -u aurbuild -- makepkg --printsrcinfo > "$WORKDIR/srcinfo"
39mv "$WORKDIR/srcinfo" .SRCINFO
40chown -R root:root "$dest"
41git config --global --add safe.directory '*'
42git config user.name "$AUR_GIT_AUTHOR_NAME"
43git config user.email "$AUR_GIT_AUTHOR_EMAIL"
44git add -A
45if git diff --cached --quiet; then echo "AUR $pkg already up to date ($ver)"; exit 0; fi
46git commit -qm "$ver"
47git push -u origin HEAD:master
48echo "AUR updated: $pkg $ver"