|
| 1 | +name: AUR Package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'aur/**' |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + - 'aur/**' |
| 10 | + workflow_run: |
| 11 | + workflows: ["Build and Release"] |
| 12 | + types: [completed] |
| 13 | + |
| 14 | +jobs: |
| 15 | + validate: |
| 16 | + name: Validate PKGBUILDs |
| 17 | + if: github.event_name != 'workflow_run' |
| 18 | + runs-on: ubuntu-latest |
| 19 | + container: archlinux:base-devel |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Setup build user |
| 25 | + run: | |
| 26 | + useradd -m builder |
| 27 | + echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers |
| 28 | + chown -R builder:builder . |
| 29 | +
|
| 30 | + - name: Install namcap |
| 31 | + run: pacman -Sy --noconfirm namcap |
| 32 | + |
| 33 | + - name: Lint lcl-bin PKGBUILD |
| 34 | + working-directory: aur/lcl-bin |
| 35 | + run: namcap PKGBUILD |
| 36 | + |
| 37 | + - name: Validate lcl-bin .SRCINFO |
| 38 | + working-directory: aur/lcl-bin |
| 39 | + run: | |
| 40 | + su builder -c "makepkg --printsrcinfo" > .SRCINFO.generated |
| 41 | + diff -u .SRCINFO .SRCINFO.generated |
| 42 | +
|
| 43 | + - name: Lint lcl-gui-bin PKGBUILD |
| 44 | + working-directory: aur/lcl-gui-bin |
| 45 | + run: namcap PKGBUILD |
| 46 | + |
| 47 | + - name: Validate lcl-gui-bin .SRCINFO |
| 48 | + working-directory: aur/lcl-gui-bin |
| 49 | + run: | |
| 50 | + su builder -c "makepkg --printsrcinfo" > .SRCINFO.generated |
| 51 | + diff -u .SRCINFO .SRCINFO.generated |
| 52 | +
|
| 53 | + publish: |
| 54 | + name: Publish to AUR |
| 55 | + if: github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' |
| 56 | + runs-on: ubuntu-latest |
| 57 | + container: archlinux:base-devel |
| 58 | + steps: |
| 59 | + - name: Checkout |
| 60 | + uses: actions/checkout@v4 |
| 61 | + |
| 62 | + - name: Setup build user |
| 63 | + run: | |
| 64 | + useradd -m builder |
| 65 | + echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers |
| 66 | +
|
| 67 | + - name: Install dependencies |
| 68 | + run: pacman -Sy --noconfirm openssh git |
| 69 | + |
| 70 | + - name: Get version from release |
| 71 | + id: version |
| 72 | + run: echo "version=$(echo '${{ github.event.workflow_run.head_branch }}' | sed 's/^v//')" >> $GITHUB_OUTPUT |
| 73 | + |
| 74 | + - name: Update PKGBUILDs and checksums |
| 75 | + run: | |
| 76 | + VERSION="${{ steps.version.outputs.version }}" |
| 77 | +
|
| 78 | + # Download CLI zip and compute SHA256 |
| 79 | + CLI_URL="https://github.com/SimonSchubert/LinuxCommandLibrary/releases/download/v${VERSION}/LinuxCommandLibrary-${VERSION}-cli-linux-x64.zip" |
| 80 | + curl -L -o cli.zip "$CLI_URL" |
| 81 | + CLI_SHA256=$(sha256sum cli.zip | cut -d' ' -f1) |
| 82 | + rm cli.zip |
| 83 | +
|
| 84 | + # Download GUI tarball and compute SHA256 |
| 85 | + GUI_URL="https://github.com/SimonSchubert/LinuxCommandLibrary/releases/download/v${VERSION}/LinuxCommandLibrary-${VERSION}-linux-x86_64.tar.gz" |
| 86 | + curl -L -o gui.tar.gz "$GUI_URL" |
| 87 | + GUI_SHA256=$(sha256sum gui.tar.gz | cut -d' ' -f1) |
| 88 | + rm gui.tar.gz |
| 89 | +
|
| 90 | + # Update lcl-bin PKGBUILD |
| 91 | + cd aur/lcl-bin |
| 92 | + sed -i "s|^pkgver=.*|pkgver=${VERSION}|" PKGBUILD |
| 93 | + sed -i "s|^pkgrel=.*|pkgrel=1|" PKGBUILD |
| 94 | + sed -i "s|^sha256sums=.*|sha256sums=('${CLI_SHA256}')|" PKGBUILD |
| 95 | + chown -R builder:builder . |
| 96 | + su builder -c "makepkg --printsrcinfo" > .SRCINFO |
| 97 | + echo "=== lcl-bin PKGBUILD ===" |
| 98 | + cat PKGBUILD |
| 99 | +
|
| 100 | + # Update lcl-gui-bin PKGBUILD |
| 101 | + cd ../lcl-gui-bin |
| 102 | + sed -i "s|^pkgver=.*|pkgver=${VERSION}|" PKGBUILD |
| 103 | + sed -i "s|^pkgrel=.*|pkgrel=1|" PKGBUILD |
| 104 | + sed -i "s|^sha256sums=.*|sha256sums=('${GUI_SHA256}')|" PKGBUILD |
| 105 | + chown -R builder:builder . |
| 106 | + su builder -c "makepkg --printsrcinfo" > .SRCINFO |
| 107 | + echo "=== lcl-gui-bin PKGBUILD ===" |
| 108 | + cat PKGBUILD |
| 109 | +
|
| 110 | + - name: Push to AUR |
| 111 | + env: |
| 112 | + AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }} |
| 113 | + run: | |
| 114 | + # Setup SSH - use system-wide known_hosts to avoid HOME mismatch in containers |
| 115 | + echo "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN" >> /etc/ssh/ssh_known_hosts |
| 116 | + for dir in "$HOME" "/root"; do |
| 117 | + mkdir -p "$dir/.ssh" |
| 118 | + echo "$AUR_SSH_KEY" > "$dir/.ssh/aur" |
| 119 | + chmod 600 "$dir/.ssh/aur" |
| 120 | + printf "Host aur.archlinux.org\n IdentityFile %s/.ssh/aur\n User aur\n" "$dir" > "$dir/.ssh/config" |
| 121 | + chmod 700 "$dir/.ssh" |
| 122 | + chmod 600 "$dir/.ssh/config" |
| 123 | + done |
| 124 | +
|
| 125 | + git config --global user.name "Simon Schubert" |
| 126 | + git config --global user.email "sschubert89@gmail.com" |
| 127 | +
|
| 128 | + VERSION="${{ steps.version.outputs.version }}" |
| 129 | +
|
| 130 | + # Push lcl-bin |
| 131 | + cd /tmp |
| 132 | + git clone ssh://aur@aur.archlinux.org/lcl-bin.git |
| 133 | + cp $GITHUB_WORKSPACE/aur/lcl-bin/PKGBUILD lcl-bin/ |
| 134 | + cp $GITHUB_WORKSPACE/aur/lcl-bin/.SRCINFO lcl-bin/ |
| 135 | + cd lcl-bin |
| 136 | + git add PKGBUILD .SRCINFO |
| 137 | + git commit -m "Update to ${VERSION}" |
| 138 | + git push |
| 139 | +
|
| 140 | + # Push lcl-gui-bin |
| 141 | + cd /tmp |
| 142 | + git clone ssh://aur@aur.archlinux.org/lcl-gui-bin.git |
| 143 | + cp $GITHUB_WORKSPACE/aur/lcl-gui-bin/PKGBUILD lcl-gui-bin/ |
| 144 | + cp $GITHUB_WORKSPACE/aur/lcl-gui-bin/.SRCINFO lcl-gui-bin/ |
| 145 | + cd lcl-gui-bin |
| 146 | + git add PKGBUILD .SRCINFO |
| 147 | + git commit -m "Update to ${VERSION}" |
| 148 | + git push |
| 149 | +
|
| 150 | + - name: Update repo PKGBUILDs |
| 151 | + env: |
| 152 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 153 | + run: | |
| 154 | + VERSION="${{ steps.version.outputs.version }}" |
| 155 | +
|
| 156 | + cd /tmp |
| 157 | + git clone --depth 1 https://x-access-token:${GITHUB_TOKEN}@github.com/SimonSchubert/LinuxCommandLibrary.git lcl-repo |
| 158 | + cd lcl-repo |
| 159 | +
|
| 160 | + git config user.name "github-actions[bot]" |
| 161 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 162 | +
|
| 163 | + cp $GITHUB_WORKSPACE/aur/lcl-bin/PKGBUILD aur/lcl-bin/PKGBUILD |
| 164 | + cp $GITHUB_WORKSPACE/aur/lcl-bin/.SRCINFO aur/lcl-bin/.SRCINFO |
| 165 | + cp $GITHUB_WORKSPACE/aur/lcl-gui-bin/PKGBUILD aur/lcl-gui-bin/PKGBUILD |
| 166 | + cp $GITHUB_WORKSPACE/aur/lcl-gui-bin/.SRCINFO aur/lcl-gui-bin/.SRCINFO |
| 167 | +
|
| 168 | + git add aur/ |
| 169 | + git commit -m "Update AUR packages to ${VERSION}" || exit 0 |
| 170 | + git push |
0 commit comments