From e5f36053aff760a1a9f3d9a7f48a21daccd412ae Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sat, 17 Sep 2022 16:12:29 +0200 Subject: [PATCH] [workflow] add experimental AUR release workflow OK, so I don't know how to test this, but *theoretically*, this should automatically push releases to AUR. --- .github/workflows/aurpublish.yml | 29 ++++++++++++++++++++ PKGBUILD.template | 45 ++++++++++++++++++++++++++++++++ create-pkgbuild.py | 28 ++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 .github/workflows/aurpublish.yml create mode 100644 PKGBUILD.template create mode 100644 create-pkgbuild.py diff --git a/.github/workflows/aurpublish.yml b/.github/workflows/aurpublish.yml new file mode 100644 index 0000000..c2ede44 --- /dev/null +++ b/.github/workflows/aurpublish.yml @@ -0,0 +1,29 @@ +--- +name: Upload AUR Package + +on: + release: + types: [created] + +jobs: + aur-publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install requests + - name: Create PKGBUILD + run: | + python ./create-pkgbuild.py > ./PKGBUILD + - name: Publish AUR package + uses: KSXGitHub/github-actions-deploy-aur@v2.5.0 + with: + pkgname: bumblebee-status + pkgbuild: ./PKGBUILD + commit_username: ${{ secrets.AUR_USERNAME }} + commit_email: ${{ secrets.AUR_EMAIL }} + ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + commit_message: Update AUR package + ssh_keyscan_types: rsa,dsa,ecdsa,ed25519 diff --git a/PKGBUILD.template b/PKGBUILD.template new file mode 100644 index 0000000..08b511d --- /dev/null +++ b/PKGBUILD.template @@ -0,0 +1,45 @@ +# Maintainer: Tobias Witek +# Contributor: Daniel M. Capella +# Contributor: spookykidmm + +pkgname=bumblebee-status +pkgver= +pkgrel=1 +pkgdesc='Modular, theme-able status line generator for the i3 window manager' +arch=('any') +url=https://github.com/tobi-wan-kenobi/bumblebee-status +license=('MIT') +depends=('python' 'python-netifaces' 'python-psutil' 'python-requests') +optdepends=('xorg-xbacklight: to display a displays brightness' + 'xorg-xset: enable/disable automatic screen locking' + 'libnotify: enable/disable automatic screen locking' + 'dnf: display DNF package update information' + 'xorg-setxkbmap: display/change the current keyboard layout' + 'redshift: display the redshifts current color' + 'pulseaudio: control pulseaudio sink/sources' + 'xorg-xrandr: enable/disable screen outputs' + 'pacman: display current status of pacman' + 'iputils: display a ping' + 'python-i3ipc: display titlebar' + 'fakeroot: dependency of the pacman module' + 'python-pytz: timezone conversion for datetimetz module' + 'python-tzlocal: retrieve system timezone for datetimetz module' +) +source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz") +sha512sums=('') + +package() { + install -d "$pkgdir"/usr/bin \ + "$pkgdir"/usr/share/$pkgname/bumblebee_status/{core,util} \ + "$pkgdir"/usr/share/$pkgname/bumblebee_status/modules/{core,contrib} \ + "$pkgdir"/usr/share/$pkgname/themes/icons + ln -s /usr/share/$pkgname/$pkgname "$pkgdir"/usr/bin/$pkgname + ln -s /usr/share/$pkgname/bumblebee-ctl "$pkgdir"/usr/bin/bumblebee-ctl + + cd $pkgname-$pkgver + cp -a --parents $pkgname bumblebee_status/{,core/,util/,modules/core/,modules/contrib/}*.py \ + themes/{,icons/}*.json $pkgdir/usr/share/$pkgname + cp -r bin $pkgdir/usr/share/$pkgname/ + + install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE +} diff --git a/create-pkgbuild.py b/create-pkgbuild.py new file mode 100644 index 0000000..0ab79e3 --- /dev/null +++ b/create-pkgbuild.py @@ -0,0 +1,28 @@ +#!/bin/bash + +import sys +import json +import hashlib +import requests + +rv = requests.request( + "GET", + "https://api.github.com/repos/tobi-wan-kenobi/bumblebee-status/releases/latest", +) + +if rv.status_code != 200: + sys.exit(1) + +release = json.loads(rv.text) + +tar = requests.get(f"https://github.com/tobi-wan-kenobi/bumblebee-status/archive/{release['name']}.tar.gz") +checksum = hashlib.sha512(tar.content).hexdigest() + +template = "" +with open("./PKGBUILD.template") as f: + template = f.read() + +template = template.replace("", release["name"].lstrip("v")) +template = template.replace("", checksum) + +print(template)