Skip to content

Commit 0a61813

Browse files
committed
feat: add AUR publishing support with CI workflow
Add PKGBUILD and .SRCINFO templates for codeinput and codeinput-bin AUR packages, a GitHub Actions workflow to automate publishing on release, and a helper script to regenerate .SRCINFO from PKGBUILDs.
1 parent c2800dc commit 0a61813

7 files changed

Lines changed: 255 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env bash
2+
# Generate .SRCINFO from a PKGBUILD file.
3+
# Usage: generate-srcinfo.sh <PKGBUILD_PATH>
4+
#
5+
# Sources the PKGBUILD in a restricted subshell and outputs .SRCINFO format.
6+
7+
set -uo pipefail
8+
9+
if [ $# -lt 1 ]; then
10+
echo "Usage: $0 <PKGBUILD_PATH>" >&2
11+
exit 1
12+
fi
13+
14+
pkgbuild="$1"
15+
16+
if [ ! -f "$pkgbuild" ]; then
17+
echo "Error: $pkgbuild not found" >&2
18+
exit 1
19+
fi
20+
21+
(
22+
# Override functions that might cause side effects
23+
build() { :; }
24+
package() { :; }
25+
prepare() { :; }
26+
check() { :; }
27+
28+
source "$pkgbuild"
29+
30+
# Determine pkgbase (defaults to first pkgname)
31+
base="${pkgbase:-${pkgname[0]:-${pkgname:-}}}"
32+
33+
# pkgbase section
34+
echo "pkgbase = ${base}"
35+
[ -n "${pkgdesc:-}" ] && printf '\tpkgdesc = %s\n' "$pkgdesc"
36+
[ -n "${pkgver:-}" ] && printf '\tpkgver = %s\n' "$pkgver"
37+
[ -n "${pkgrel:-}" ] && printf '\tpkgrel = %s\n' "$pkgrel"
38+
[ -n "${url:-}" ] && printf '\turl = %s\n' "$url"
39+
40+
# Array fields
41+
for v in "${arch[@]}"; do printf '\tarch = %s\n' "$v"; done 2>/dev/null || true
42+
for v in "${license[@]}"; do printf '\tlicense = %s\n' "$v"; done 2>/dev/null || true
43+
for v in "${depends[@]}"; do printf '\tdepends = %s\n' "$v"; done 2>/dev/null || true
44+
for v in "${makedepends[@]}"; do printf '\tmakedepends = %s\n' "$v"; done 2>/dev/null || true
45+
for v in "${checkdepends[@]}"; do printf '\tcheckdepends = %s\n' "$v"; done 2>/dev/null || true
46+
for v in "${optdepends[@]}"; do printf '\toptdepends = %s\n' "$v"; done 2>/dev/null || true
47+
for v in "${provides[@]}"; do printf '\tprovides = %s\n' "$v"; done 2>/dev/null || true
48+
for v in "${conflicts[@]}"; do printf '\tconflicts = %s\n' "$v"; done 2>/dev/null || true
49+
for v in "${replaces[@]}"; do printf '\treplaces = %s\n' "$v"; done 2>/dev/null || true
50+
for v in "${groups[@]}"; do printf '\tgroups = %s\n' "$v"; done 2>/dev/null || true
51+
for v in "${options[@]}"; do printf '\toptions = %s\n' "$v"; done 2>/dev/null || true
52+
for v in "${source[@]}"; do printf '\tsource = %s\n' "$v"; done 2>/dev/null || true
53+
for v in "${sha256sums[@]}"; do printf '\tsha256sums = %s\n' "$v"; done 2>/dev/null || true
54+
for v in "${sha512sums[@]}"; do printf '\tsha512sums = %s\n' "$v"; done 2>/dev/null || true
55+
for v in "${md5sums[@]}"; do printf '\tmd5sums = %s\n' "$v"; done 2>/dev/null || true
56+
57+
# Architecture-specific arrays
58+
for v in "${source_x86_64[@]}"; do printf '\tsource_x86_64 = %s\n' "$v"; done 2>/dev/null || true
59+
for v in "${source_aarch64[@]}"; do printf '\tsource_aarch64 = %s\n' "$v"; done 2>/dev/null || true
60+
for v in "${sha256sums_x86_64[@]}"; do printf '\tsha256sums_x86_64 = %s\n' "$v"; done 2>/dev/null || true
61+
for v in "${sha256sums_aarch64[@]}"; do printf '\tsha256sums_aarch64 = %s\n' "$v"; done 2>/dev/null || true
62+
for v in "${sha512sums_x86_64[@]}"; do printf '\tsha512sums_x86_64 = %s\n' "$v"; done 2>/dev/null || true
63+
for v in "${sha512sums_aarch64[@]}"; do printf '\tsha512sums_aarch64 = %s\n' "$v"; done 2>/dev/null || true
64+
65+
echo ""
66+
67+
# pkgname sections
68+
if declare -p pkgname 2>/dev/null | grep -q 'declare -a'; then
69+
for name in "${pkgname[@]}"; do
70+
echo "pkgname = ${name}"
71+
done
72+
else
73+
echo "pkgname = ${pkgname}"
74+
fi
75+
) 2>/dev/null

.github/workflows/publish-aur.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Publish to AUR
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish-aur:
9+
name: Publish ${{ matrix.package }} to AUR
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
include:
14+
- package: codeinput-bin
15+
subdir: codeinput-bin
16+
- package: codeinput
17+
subdir: codeinput
18+
steps:
19+
- name: Checkout Source
20+
uses: actions/checkout@v4
21+
22+
- name: Get version
23+
id: version
24+
run: |
25+
tag="${GITHUB_REF#refs/tags/}"
26+
version="${tag#v}"
27+
echo "tag=${tag}" >> $GITHUB_OUTPUT
28+
echo "version=${version}" >> $GITHUB_OUTPUT
29+
30+
- name: Compute binary checksums
31+
if: matrix.package == 'codeinput-bin'
32+
id: checksums
33+
run: |
34+
curl -sL "https://github.com/code-input/cli/releases/download/${{ steps.version.outputs.tag }}/ci-linux-x86_64" -o ci-linux-x86_64
35+
echo "sha256_x86_64=$(sha256sum ci-linux-x86_64 | cut -d' ' -f1)" >> $GITHUB_OUTPUT
36+
curl -sL "https://github.com/code-input/cli/releases/download/${{ steps.version.outputs.tag }}/ci-linux-aarch64" -o ci-linux-aarch64
37+
echo "sha256_aarch64=$(sha256sum ci-linux-aarch64 | cut -d' ' -f1)" >> $GITHUB_OUTPUT
38+
39+
- name: Compute source checksum
40+
if: matrix.package == 'codeinput'
41+
id: src_checksum
42+
run: |
43+
curl -sL "https://github.com/code-input/cli/archive/refs/tags/${{ steps.version.outputs.tag }}.tar.gz" -o source.tar.gz
44+
echo "sha256=$(sha256sum source.tar.gz | cut -d' ' -f1)" >> $GITHUB_OUTPUT
45+
46+
- name: Update PKGBUILD
47+
working-directory: dist/aur/${{ matrix.subdir }}
48+
run: |
49+
sed -i "s/^pkgver=.*/pkgver=${{ steps.version.outputs.version }}/" PKGBUILD
50+
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
51+
52+
if [ "${{ matrix.package }}" = "codeinput-bin" ]; then
53+
sed -i "s/^sha256sums_x86_64=.*/sha256sums_x86_64=('${{ steps.checksums.outputs.sha256_x86_64 }}')/" PKGBUILD
54+
sed -i "s/^sha256sums_aarch64=.*/sha256sums_aarch64=('${{ steps.checksums.outputs.sha256_aarch64 }}')/" PKGBUILD
55+
else
56+
sed -i "s/^sha256sums=.*/sha256sums=('${{ steps.src_checksum.outputs.sha256 }}')/" PKGBUILD
57+
fi
58+
59+
- name: Generate .SRCINFO
60+
working-directory: dist/aur/${{ matrix.subdir }}
61+
run: |
62+
bash "${{ github.workspace }}/.github/scripts/generate-srcinfo.sh" PKGBUILD > .SRCINFO
63+
64+
- name: Publish to AUR
65+
env:
66+
AUR_USERNAME: ${{ secrets.AUR_USERNAME }}
67+
AUR_EMAIL: ${{ secrets.AUR_EMAIL }}
68+
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
69+
PACKAGE: ${{ matrix.package }}
70+
SUBDIR: ${{ matrix.subdir }}
71+
run: |
72+
# Setup SSH
73+
mkdir -p ~/.ssh
74+
echo "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur
75+
chmod 600 ~/.ssh/aur
76+
cat >> ~/.ssh/config <<EOF
77+
Host aur.archlinux.org
78+
IdentityFile ~/.ssh/aur
79+
User aur
80+
StrictHostKeyChecking no
81+
EOF
82+
83+
# Clone, update, and push to AUR
84+
git clone "ssh://aur@aur.archlinux.org/${PACKAGE}.git" "/tmp/${PACKAGE}"
85+
cp "dist/aur/${SUBDIR}/PKGBUILD" "/tmp/${PACKAGE}/PKGBUILD"
86+
cp "dist/aur/${SUBDIR}/.SRCINFO" "/tmp/${PACKAGE}/.SRCINFO"
87+
88+
cd "/tmp/${PACKAGE}"
89+
git config user.name "$AUR_USERNAME"
90+
git config user.email "$AUR_EMAIL"
91+
git add PKGBUILD .SRCINFO
92+
git commit -m "Update to ${{ steps.version.outputs.version }}"
93+
git push

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ cargo build --release --bin ci
9393
sudo cp target/release/ci /usr/local/bin/
9494
```
9595

96+
### Arch Linux (AUR)
97+
98+
Install from the [Arch User Repository](https://aur.archlinux.org/) using an AUR helper:
99+
100+
```bash
101+
yay -S codeinput # build from source
102+
yay -S codeinput-bin # pre-built binary
103+
```
104+
96105
### From NPM
97106

98107
```bash

dist/aur/codeinput-bin/.SRCINFO

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pkgbase = codeinput-bin
2+
pkgdesc = A powerful CLI tool for parsing, analyzing, and managing CODEOWNERS files
3+
pkgver = 0.1.0
4+
pkgrel = 1
5+
url = https://codeinput.com/cli
6+
arch = x86_64
7+
arch = aarch64
8+
license = MIT
9+
provides = codeinput
10+
conflicts = codeinput
11+
options = !strip
12+
source_x86_64 = https://github.com/code-input/cli/releases/download/v0.1.0/ci-linux-x86_64
13+
sha256sums_x86_64 = SKIP
14+
source_aarch64 = https://github.com/code-input/cli/releases/download/v0.1.0/ci-linux-aarch64
15+
sha256sums_aarch64 = SKIP
16+
17+
pkgname = codeinput-bin

dist/aur/codeinput-bin/PKGBUILD

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Maintainer: Abid Omar <contact@omarabid.com>
2+
pkgname=codeinput-bin
3+
pkgver=0.1.0
4+
pkgrel=1
5+
pkgdesc="A powerful CLI tool for parsing, analyzing, and managing CODEOWNERS files"
6+
arch=('x86_64' 'aarch64')
7+
url="https://codeinput.com/cli"
8+
license=('MIT')
9+
provides=('codeinput')
10+
conflicts=('codeinput')
11+
options=('!strip')
12+
source_x86_64=("https://github.com/code-input/cli/releases/download/v${pkgver}/ci-linux-x86_64")
13+
source_aarch64=("https://github.com/code-input/cli/releases/download/v${pkgver}/ci-linux-aarch64")
14+
sha256sums_x86_64=('SKIP')
15+
sha256sums_aarch64=('SKIP')
16+
17+
package() {
18+
install -Dm755 "${srcdir}/ci-linux-${CARCH}" "${pkgdir}/usr/bin/ci"
19+
}

dist/aur/codeinput/.SRCINFO

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pkgbase = codeinput
2+
pkgdesc = A powerful CLI tool for parsing, analyzing, and managing CODEOWNERS files
3+
pkgver = 0.1.0
4+
pkgrel = 1
5+
url = https://codeinput.com/cli
6+
arch = x86_64
7+
arch = aarch64
8+
license = MIT
9+
depends = gcc
10+
depends = openssl
11+
makedepends = cargo
12+
source = codeinput-0.1.0.tar.gz::https://github.com/code-input/cli/archive/refs/tags/v0.1.0.tar.gz
13+
sha256sums = SKIP
14+
15+
pkgname = codeinput

dist/aur/codeinput/PKGBUILD

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Maintainer: Abid Omar <contact@omarabid.com>
2+
pkgname=codeinput
3+
pkgver=0.1.0
4+
pkgrel=1
5+
pkgdesc="A powerful CLI tool for parsing, analyzing, and managing CODEOWNERS files"
6+
arch=('x86_64' 'aarch64')
7+
url="https://codeinput.com/cli"
8+
license=('MIT')
9+
depends=('gcc' 'openssl')
10+
makedepends=('cargo')
11+
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/code-input/cli/archive/refs/tags/v${pkgver}.tar.gz")
12+
sha256sums=('SKIP')
13+
14+
prepare() {
15+
cd "cli-${pkgver}"
16+
cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
17+
}
18+
19+
build() {
20+
cd "cli-${pkgver}"
21+
cargo build --release --bin ci
22+
}
23+
24+
package() {
25+
cd "cli-${pkgver}"
26+
install -Dm755 "target/release/ci" "${pkgdir}/usr/bin/ci"
27+
}

0 commit comments

Comments
 (0)