From 06b7d81d91b5890571c6c2f7730f77331ca9ab46 Mon Sep 17 00:00:00 2001 From: mxmlnkn Date: Sun, 10 Dec 2023 10:01:49 +0100 Subject: [PATCH] [wip][CI] Automatically publish to AUR --- .github/workflows/publish-rapidgzip.yml | 46 +++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-rapidgzip.yml b/.github/workflows/publish-rapidgzip.yml index 22f40c79..957dd90d 100644 --- a/.github/workflows/publish-rapidgzip.yml +++ b/.github/workflows/publish-rapidgzip.yml @@ -2,11 +2,12 @@ name: Publish Rapidgzip to PyPI on: push: - tags: - - 'rapidgzip-v*.*.*' + branches: + - 'oldmaster' jobs: Deploy-Wheels: + if: false runs-on: ${{ matrix.os }} strategy: @@ -194,3 +195,44 @@ jobs: python3 -m build -o . --sdist .. mv rapidgzip-*.tar* src.tar conda build --token "$ANACONDA_TOKEN" . + + Deploy-AUR: + runs-on: ubuntu-latest + container: + image: archlinux + steps: + - name: Set Up Non-Root User # Because makepkg is an ass and forbids root from using it + run: | + groupadd sudo + useradd -m -G sudo user + echo '%sudo ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers + + - name: Install System Dependencies + run: | + pacman -Syu --noconfirm + pacman -Sy --noconfirm base-devel git python python-pip python-setuptools rhash + + - name: Clone Repository + run: | + chmod a+rwx . + git clone https://aur.archlinux.org/python-rapidgzip.git . + # For testing whether the update script works + git checkout HEAD~ + + - name: Update PKGBUILD + run: | + # Annoyingly, --no-deps is not sufficient and building the wheels would still be triggered even + # just for downloading the source tarball! But, --no-build-isolation seems to avoid that: + # https://discuss.python.org/t/pip-download-just-the-source-packages-no-building-no-metadata-etc/4651/7 + pip download --no-binary --no-deps --no-build-isolation :all: rapidgzip + pkgver=$( echo rapidgzip-*.tar.gz | sed -E 's|rapidgzip-([0-9.]*).*[.]tar.gz|\1|' ) + blake2b=$( python3 -c 'import hashlib, sys; h=hashlib.blake2b(digest_size=256 // 8); h.update(open(sys.argv[1], "rb").read()); print(h.digest().hex())' rapidgzip-*.tar.gz ) + # Update PKGBUILD + sed -i "s|pkgver=.*|pkgver=$pkgver|" PKBUILD + sed -i "s|sha256sums=.*|sha256sums=($( rhash --sha256 rapidgzip-*.tar.gz ))|" PKBUILD + sed -i "s|(.*pythonhosted.org/packages)/[0-9][0-9]/[0-9][0-9]/[0-9]*/(.*)|\1/${blake2b:0:2}/${blake2b:2:2}/${blake2b:4}\2" PKGBUILD + + - name: Test PKGBUILD + run: | + su user -c 'makepkg -s --noconfirm' + su user -c 'makepkg --noconfirm --install python-rapidgzip-*.tar.zst'