[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.
This commit is contained in:
tobi-wan-kenobi 2022-09-17 16:12:29 +02:00
parent d94ee9416a
commit e5f36053af
3 changed files with 102 additions and 0 deletions

29
.github/workflows/aurpublish.yml vendored Normal file
View file

@ -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

45
PKGBUILD.template Normal file
View file

@ -0,0 +1,45 @@
# Maintainer: Tobias Witek <tobi@tobi-wan-kenobi.at>
# Contributor: Daniel M. Capella <polycitizen@gmail.com>
# Contributor: spookykidmm <https://github.com/spookykidmm>
pkgname=bumblebee-status
pkgver=<PKGVERSION>
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=('<SHA512SUM>')
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
}

28
create-pkgbuild.py Normal file
View file

@ -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("<PKGVERSION>", release["name"].lstrip("v"))
template = template.replace("<SHA512SUM>", checksum)
print(template)