@@ -2,75 +2,78 @@ name: Publish AUR Package
22
33on :
44 push :
5- branches :
6- - workflow-test
7- # tags:
8- # - "v*"
5+ tags :
6+ - " v*"
97
108jobs :
11- publish :
9+ aur :
1210 runs-on : ubuntu-latest
1311
12+ container :
13+ image : archlinux:latest
14+ options : --user=root
15+
1416 steps :
17+ - name : Install dependencies
18+ run : |
19+ pacman -Syu --noconfirm
20+ pacman -S --noconfirm git openssh pacman-contrib sudo base-devel
21+
1522 - name : Checkout repository
1623 uses : actions/checkout@v4
1724
1825 - name : Extract version from tag
1926 id : version
20- run : echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
27+ run : |
28+ echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
2129
2230 - name : Download GitHub source tarball
2331 run : |
2432 curl -L -o source.tar.gz \
25- https://github.com/woterr/dotpush /archive/refs/tags/v${{ steps.version.outputs.VERSION }}.tar.gz
33+ https://github.com/${GITHUB_REPOSITORY} /archive/refs/tags/v${{ steps.version.outputs.VERSION }}.tar.gz
2634
27- - name : Compute sha256 checksum
35+ - name : Compute SHA256
2836 id : sha
2937 run : |
30- SHA=$(sha256sum source.tar.gz | cut -d ' ' -f1)
31- echo "SHA256=$SHA" >> $GITHUB_OUTPUT
32-
33- - name : Update PKGBUILD + Push to AUR (in Arch container)
34- uses : docker://archlinux:latest
35- with :
36- entrypoint : /bin/bash
37- args : |
38- -c "
39- pacman -Sy --noconfirm git openssh pacman-contrib sudo
40-
41- # Setup SSH for root (git push will run as root)
42- mkdir -p /root/.ssh
43- echo '${{ secrets.AUR_SSH_PRIVATE_KEY }}' > /root/.ssh/id_ed25519
44- chmod 600 /root/.ssh/id_ed25519
45-
46- echo 'Host aur.archlinux.org
47- HostName aur.archlinux.org
48- User aur
49- IdentityFile /root/.ssh/id_ed25519
50- ' > /root/.ssh/config
51-
52- ssh-keyscan aur.archlinux.org >> /root/.ssh/known_hosts
53-
54- # Clone repo as root
55- git clone ssh://aur@aur.archlinux.org/${{ secrets.AUR_REPO }}.git /aur-repo
56-
57- # Create builder user
58- useradd -m builder
59- chown -R builder:builder /aur-repo
60-
61- # Update PKGBUILD and build .SRCINFO as builder (non-root)
62- sudo -u builder bash -c '
63- cd /aur-repo
64- sed -i \"s/^pkgver=.*/pkgver=${{ steps.version.outputs.VERSION }}/\" PKGBUILD
65- sed -i \"s/^sha256sums=.*/sha256sums=(\\\"${{ steps.sha.outputs.SHA256 }}\\\")/\" PKGBUILD
66- makepkg --printsrcinfo > .SRCINFO
67- '
68-
69- # Commit + push as root
70- cd /aur-repo
71- git config user.name '${{ secrets.AUR_USERNAME }}'
72- git config user.email 'actions@github.com'
73- git add PKGBUILD .SRCINFO
74- git commit -m 'Update to v${{ steps.version.outputs.VERSION }}' || echo 'No changes'
75- git push
76- "
38+ sha=$(sha256sum source.tar.gz | cut -d ' ' -f1)
39+ echo "SHA256=$sha" >> $GITHUB_OUTPUT
40+
41+ - name : Setup SSH for AUR
42+ run : |
43+ mkdir -p ~/.ssh
44+ echo "${{ secrets.AUR_SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
45+ chmod 600 ~/.ssh/id_ed25519
46+
47+ cat << 'EOF' > ~/.ssh/config
48+ Host aur.archlinux.org
49+ HostName aur.archlinux.org
50+ User aur
51+ IdentityFile ~/.ssh/id_ed25519
52+ EOF
53+
54+ ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
55+ chmod 644 ~/.ssh/known_hosts
56+
57+
58+
59+
60+ - name : Clone AUR repository
61+ run : |
62+ git config --global --add safe.directory /aur-repo
63+ git clone ssh://aur@aur.archlinux.org/${{ secrets.AUR_REPO }}.git /aur-repo
64+
65+ - name : Update PKGBUILD
66+ run : |
67+ cd /aur-repo
68+ sed -i "s/^pkgver=.*/pkgver=${{ steps.version.outputs.VERSION }}/" PKGBUILD
69+ sed -i "s/^sha256sums=.*/sha256sums=('${{ steps.sha.outputs.SHA256 }}')/" PKGBUILD
70+ makepkg --printsrcinfo > .SRCINFO
71+
72+ - name : Commit and Push
73+ run : |
74+ cd /aur-repo
75+ git config user.name "${{ secrets.AUR_USERNAME }}"
76+ git config user.email "actions@github.com"
77+ git add PKGBUILD .SRCINFO
78+ git commit -m "Update to v${{ steps.version.outputs.VERSION }}" || true
79+ git push
0 commit comments