Skip to content

Commit 387afdc

Browse files
committed
Fix AUR workflow: use direct SSH, add local testing with act
- Rewrote AUR workflow to use direct SSH to aur.archlinux.org - Added .github/aur/ with PKGBUILD and .SRCINFO templates - Added Makefile targets for local workflow testing (make test-aur, etc) - Fixed flake.nix to auto-detect version from pyproject.toml
1 parent 1b0ec00 commit 387afdc

4 files changed

Lines changed: 74 additions & 38 deletions

File tree

.github/aur/.SRCINFO

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pkgbase = gitfetch-python
2+
pkgdesc = A neofetch-style CLI tool for GitHub statistics
3+
pkgver = 1.3.2
4+
pkgrel = 1
5+
url = https://github.com/Matars/gitfetch
6+
arch = any
7+
license = GPL-2.0
8+
makedepends = python-requests
9+
makedepends = python-readchar
10+
makedepends = python-pip
11+
depends = python-requests
12+
depends = python-readchar
13+
source = gitfetch-python-1.3.2.tar.gz::https://github.com/Matars/gitfetch/archive/refs/tags/v1.3.2.tar.gz
14+
sha256sums = 8f3ec7969798dbc929f07665d980b51d4b27d420240a249989edd2b1bda4b4c4
15+
16+
pkgname = gitfetch-python

.github/aur/PKGBUILD

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Maintainer: Matar <khaledmatar19733@gmail.com>
2+
pkgname=gitfetch-python
3+
pkgver=1.3.2
4+
pkgrel=1
5+
pkgdesc="A neofetch-style CLI tool for GitHub statistics"
6+
arch=('any')
7+
url="https://github.com/Matars/gitfetch"
8+
license=('GPL-2.0')
9+
depends=("python-requests" "python-readchar")
10+
makedepends=("python-requests" "python-readchar" "python-pip")
11+
provides=('gitfetch')
12+
source=("$pkgname-$pkgver.tar.gz::https://github.com/Matars/gitfetch/archive/refs/tags/v$pkgver.tar.gz")
13+
sha256sums=('8f3ec7969798dbc929f07665d980b51d4b27d420240a249989edd2b1bda4b4c4')
14+
15+
package() {
16+
cd "gitfetch-$pkgver"
17+
python -m pip install --root="$pkgdir" --no-deps --no-warn-script-location .
18+
}

.github/workflows/update-aur.yml

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Update AUR Package
33
on:
44
release:
55
types: [published]
6+
workflow_dispatch:
67

78
jobs:
89
update-aur:
@@ -11,64 +12,53 @@ jobs:
1112
steps:
1213
- name: Checkout main repo
1314
uses: actions/checkout@v4
14-
with:
15-
repository: Matars/gitfetch
16-
path: gitfetch
1715

1816
- name: Get version from pyproject.toml
1917
id: get_version
2018
run: |
21-
VERSION=$(grep '^version =' gitfetch/pyproject.toml | sed 's/version = "\(.*\)"/\1/')
19+
VERSION=$(grep '^version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
2220
echo "version=$VERSION" >> $GITHUB_OUTPUT
2321
24-
- name: Install AUR tools
22+
- name: Update PKGBUILD and .SRCINFO
2523
run: |
26-
sudo apt-get update
27-
sudo apt-get install -y git
28-
29-
- name: Setup SSH for AUR
30-
run: |
31-
mkdir -p ~/.ssh
32-
echo "${{ secrets.AUR_SSH_KEY }}" > ~/.ssh/aur_key
33-
chmod 600 ~/.ssh/aur_key
34-
echo "Host aur.archlinux.org" >> ~/.ssh/config
35-
echo " IdentityFile ~/.ssh/aur_key" >> ~/.ssh/config
36-
echo " User aur" >> ~/.ssh/config
37-
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
38-
39-
- name: Clone AUR package
40-
run: |
41-
git clone ssh://aur@aur.archlinux.org/gitfetch-python.git aur-repo
42-
43-
- name: Update PKGBUILD
44-
run: |
45-
cd aur-repo
4624
VERSION=${{ steps.get_version.outputs.version }}
25+
cd .github/aur
4726
4827
SOURCE_URL="https://github.com/Matars/gitfetch/archive/refs/tags/v${VERSION}.tar.gz"
4928
SHA256=$(curl -sL "$SOURCE_URL" | sha256sum | awk '{print $1}')
5029
5130
sed -i "s/^pkgver=.*/pkgver=$VERSION/" PKGBUILD
5231
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
53-
sed -i "s|^source=.*|source=(\"$SOURCE_URL\")|" PKGBUILD
32+
sed -i "s|source=.*|source=(\"\$pkgname-\$pkgver.tar.gz::$SOURCE_URL\")|" PKGBUILD
5433
sed -i "s/^sha256sums=.*/sha256sums=('$SHA256')/" PKGBUILD
34+
35+
sed -i "s/pkgver = .*/pkgver = $VERSION/" .SRCINFO
36+
sed -i "s/pkgrel = .*/pkgrel = 1/" .SRCINFO
37+
sed -i "s|source = .*|source = gitfetch-python-$VERSION.tar.gz::$SOURCE_URL|" .SRCINFO
38+
sed -i "s/sha256sums = .*/sha256sums = $SHA256/" .SRCINFO
5539
56-
- name: Generate .SRCINFO
40+
- name: Setup SSH for AUR
5741
run: |
58-
cd aur-repo
59-
docker run --rm -v $(pwd):/pkg archlinux:latest /bin/bash -c "
60-
pacman -Syu --noconfirm
61-
pacman -S --noconfirm namcap sudo
62-
useradd -m builder
63-
chown -R builder:builder /pkg
64-
sudo -u builder bash -c 'cd /pkg && makepkg --printsrcinfo > .SRCINFO'
65-
"
42+
mkdir -p ~/.ssh
43+
echo "${{ secrets.AUR_SSH_KEY }}" > ~/.ssh/aur_key
44+
chmod 600 ~/.ssh/aur_key
45+
cat >> ~/.ssh/config << EOF
46+
Host aur.archlinux.org
47+
IdentityFile ~/.ssh/aur_key
48+
User aur
49+
EOF
50+
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
6651
67-
- name: Commit and push to AUR
52+
- name: Clone and update AUR
6853
run: |
54+
git clone ssh://aur@aur.archlinux.org/gitfetch-python.git aur-repo
55+
56+
cp .github/aur/PKGBUILD aur-repo/
57+
cp .github/aur/.SRCINFO aur-repo/
58+
6959
cd aur-repo
7060
git config user.name "Matar"
7161
git config user.email "khaledmatar19733@gmail.com"
7262
git add PKGBUILD .SRCINFO
73-
git commit -m "Update gitfetch-python to v${{ steps.get_version.outputs.version }}"
63+
git commit -m "Update gitfetch-python to v${{ steps.get_version.outputs.version }}" || echo "No changes to commit"
7464
git push

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: test install dev clean lint
1+
.PHONY: test install dev clean lint test-aur test-homebrew test-ci test-all
22

33
# Install dependencies
44
install:
@@ -19,3 +19,15 @@ clean:
1919
find . -type d -name .pytest_cache -exec rm -rf {} +
2020
find . -type f -name "*.pyc" -delete
2121
find . -type f -name "*.pyo" -delete
22+
23+
test-aur:
24+
act -j update-aur --container-architecture linux/amd64 --secret AUR_SSH_KEY="$$(cat ~/.ssh/aur_key)"
25+
26+
test-homebrew:
27+
act -j update-homebrew --container-architecture linux/amd64 --secret HOMEBREW_TAP_TOKEN="$$(gh auth token)"
28+
29+
test-ci:
30+
act push --container-architecture linux/amd64
31+
32+
test-all:
33+
act --container-architecture linux/amd64

0 commit comments

Comments
 (0)