|
| 1 | +name: aur publish |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["soar release", "soar nightly"] |
| 6 | + types: [completed] |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + package: |
| 10 | + description: "Package to update" |
| 11 | + required: true |
| 12 | + type: choice |
| 13 | + options: |
| 14 | + - all-stable |
| 15 | + - soar |
| 16 | + - soar-bin |
| 17 | + - soar-nightly-bin |
| 18 | + dry_run: |
| 19 | + description: "Generate PKGBUILDs without pushing to AUR" |
| 20 | + required: false |
| 21 | + type: boolean |
| 22 | + default: false |
| 23 | + |
| 24 | +jobs: |
| 25 | + update-soar: |
| 26 | + name: Update soar (source) |
| 27 | + runs-on: ubuntu-latest |
| 28 | + if: >- |
| 29 | + (github.event_name == 'workflow_dispatch' && |
| 30 | + (github.event.inputs.package == 'all-stable' || github.event.inputs.package == 'soar')) |
| 31 | + || |
| 32 | + (github.event_name == 'workflow_run' && |
| 33 | + github.event.workflow_run.conclusion == 'success' && |
| 34 | + github.event.workflow_run.name == 'soar release') |
| 35 | + steps: |
| 36 | + - name: Get latest stable version |
| 37 | + id: version |
| 38 | + env: |
| 39 | + GH_TOKEN: ${{ github.token }} |
| 40 | + run: | |
| 41 | + TAG=$(gh release list --repo "${{ github.repository }}" --exclude-pre-releases --limit 1 --json tagName --jq '.[0].tagName') |
| 42 | + if [ -z "$TAG" ] || [ "$TAG" = "null" ]; then |
| 43 | + echo "No stable release found" |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | + VERSION="${TAG#v}" |
| 47 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 48 | + echo "Detected version: $VERSION" |
| 49 | +
|
| 50 | + - name: Clone AUR package |
| 51 | + run: git clone https://aur.archlinux.org/soar.git aur-soar |
| 52 | + |
| 53 | + - name: Update PKGBUILD |
| 54 | + working-directory: aur-soar |
| 55 | + run: | |
| 56 | + sed -i "s/^pkgver=.*/pkgver=${{ steps.version.outputs.version }}/" PKGBUILD |
| 57 | + sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD |
| 58 | +
|
| 59 | + - name: Update checksums |
| 60 | + run: | |
| 61 | + docker run --rm -v "$PWD/aur-soar:/pkg" -w /pkg archlinux:base bash -lc ' |
| 62 | + set -euo pipefail |
| 63 | + pacman -Sy --noconfirm --needed pacman-contrib >/dev/null |
| 64 | + useradd -m build |
| 65 | + chown -R build:build /pkg |
| 66 | + su build -c "updpkgsums" |
| 67 | + ' |
| 68 | +
|
| 69 | + - name: Generate .SRCINFO |
| 70 | + run: | |
| 71 | + docker run --rm -v "$PWD/aur-soar:/pkg" -w /pkg archlinux:base bash -lc ' |
| 72 | + set -euo pipefail |
| 73 | + pacman -Sy --noconfirm --needed base-devel >/dev/null |
| 74 | + useradd -m build |
| 75 | + chown -R build:build /pkg |
| 76 | + su build -c "makepkg --printsrcinfo > .SRCINFO" |
| 77 | + ' |
| 78 | +
|
| 79 | + - name: Upload artifacts |
| 80 | + uses: actions/upload-artifact@v6 |
| 81 | + with: |
| 82 | + name: soar-pkgbuild |
| 83 | + path: | |
| 84 | + aur-soar/PKGBUILD |
| 85 | + aur-soar/.SRCINFO |
| 86 | +
|
| 87 | + - name: Push to AUR |
| 88 | + if: >- |
| 89 | + (github.event_name == 'workflow_run') || |
| 90 | + (github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'false') |
| 91 | + working-directory: aur-soar |
| 92 | + env: |
| 93 | + AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }} |
| 94 | + GIT_USERNAME: ${{ secrets.AUR_GIT_USERNAME || 'github-actions[bot]' }} |
| 95 | + GIT_EMAIL: ${{ secrets.AUR_GIT_EMAIL || 'github-actions[bot]@users.noreply.github.com' }} |
| 96 | + run: | |
| 97 | + sudo chown -R "$(id -u):$(id -g)" . |
| 98 | +
|
| 99 | + if git diff --quiet; then |
| 100 | + echo "No changes to push." |
| 101 | + exit 0 |
| 102 | + fi |
| 103 | +
|
| 104 | + mkdir -p ~/.ssh |
| 105 | + echo "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur |
| 106 | + chmod 600 ~/.ssh/aur |
| 107 | + echo "Host aur.archlinux.org" >> ~/.ssh/config |
| 108 | + echo " IdentityFile ~/.ssh/aur" >> ~/.ssh/config |
| 109 | + echo " StrictHostKeyChecking accept-new" >> ~/.ssh/config |
| 110 | +
|
| 111 | + git remote set-url origin ssh://aur@aur.archlinux.org/soar.git |
| 112 | + git config user.name "$GIT_USERNAME" |
| 113 | + git config user.email "$GIT_EMAIL" |
| 114 | + git add PKGBUILD .SRCINFO |
| 115 | + git commit -m "Update to ${{ steps.version.outputs.version }}" |
| 116 | + git push |
| 117 | +
|
| 118 | + update-soar-bin: |
| 119 | + name: Update soar-bin (binary) |
| 120 | + runs-on: ubuntu-latest |
| 121 | + if: >- |
| 122 | + (github.event_name == 'workflow_dispatch' && |
| 123 | + (github.event.inputs.package == 'all-stable' || github.event.inputs.package == 'soar-bin')) |
| 124 | + || |
| 125 | + (github.event_name == 'workflow_run' && |
| 126 | + github.event.workflow_run.conclusion == 'success' && |
| 127 | + github.event.workflow_run.name == 'soar release') |
| 128 | + steps: |
| 129 | + - name: Get latest stable version |
| 130 | + id: version |
| 131 | + env: |
| 132 | + GH_TOKEN: ${{ github.token }} |
| 133 | + run: | |
| 134 | + TAG=$(gh release list --repo "${{ github.repository }}" --exclude-pre-releases --limit 1 --json tagName --jq '.[0].tagName') |
| 135 | + if [ -z "$TAG" ] || [ "$TAG" = "null" ]; then |
| 136 | + echo "No stable release found" |
| 137 | + exit 1 |
| 138 | + fi |
| 139 | + VERSION="${TAG#v}" |
| 140 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 141 | + echo "Detected version: $VERSION" |
| 142 | +
|
| 143 | + - name: Clone AUR package |
| 144 | + run: git clone https://aur.archlinux.org/soar-bin.git aur-soar-bin |
| 145 | + |
| 146 | + - name: Update PKGBUILD |
| 147 | + working-directory: aur-soar-bin |
| 148 | + run: | |
| 149 | + sed -i "s/^pkgver=.*/pkgver=${{ steps.version.outputs.version }}/" PKGBUILD |
| 150 | + sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD |
| 151 | +
|
| 152 | + - name: Update checksums |
| 153 | + run: | |
| 154 | + docker run --rm -v "$PWD/aur-soar-bin:/pkg" -w /pkg archlinux:base bash -lc ' |
| 155 | + set -euo pipefail |
| 156 | + pacman -Sy --noconfirm --needed pacman-contrib >/dev/null |
| 157 | + useradd -m build |
| 158 | + chown -R build:build /pkg |
| 159 | + su build -c "updpkgsums" |
| 160 | + ' |
| 161 | +
|
| 162 | + - name: Generate .SRCINFO |
| 163 | + run: | |
| 164 | + docker run --rm -v "$PWD/aur-soar-bin:/pkg" -w /pkg archlinux:base bash -lc ' |
| 165 | + set -euo pipefail |
| 166 | + pacman -Sy --noconfirm --needed base-devel >/dev/null |
| 167 | + useradd -m build |
| 168 | + chown -R build:build /pkg |
| 169 | + su build -c "makepkg --printsrcinfo > .SRCINFO" |
| 170 | + ' |
| 171 | +
|
| 172 | + - name: Upload artifacts |
| 173 | + uses: actions/upload-artifact@v6 |
| 174 | + with: |
| 175 | + name: soar-bin-pkgbuild |
| 176 | + path: | |
| 177 | + aur-soar-bin/PKGBUILD |
| 178 | + aur-soar-bin/.SRCINFO |
| 179 | +
|
| 180 | + - name: Push to AUR |
| 181 | + if: >- |
| 182 | + (github.event_name == 'workflow_run') || |
| 183 | + (github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'false') |
| 184 | + working-directory: aur-soar-bin |
| 185 | + env: |
| 186 | + AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }} |
| 187 | + GIT_USERNAME: ${{ secrets.AUR_GIT_USERNAME || 'github-actions[bot]' }} |
| 188 | + GIT_EMAIL: ${{ secrets.AUR_GIT_EMAIL || 'github-actions[bot]@users.noreply.github.com' }} |
| 189 | + run: | |
| 190 | + sudo chown -R "$(id -u):$(id -g)" . |
| 191 | +
|
| 192 | + if git diff --quiet; then |
| 193 | + echo "No changes to push." |
| 194 | + exit 0 |
| 195 | + fi |
| 196 | +
|
| 197 | + mkdir -p ~/.ssh |
| 198 | + echo "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur |
| 199 | + chmod 600 ~/.ssh/aur |
| 200 | + echo "Host aur.archlinux.org" >> ~/.ssh/config |
| 201 | + echo " IdentityFile ~/.ssh/aur" >> ~/.ssh/config |
| 202 | + echo " StrictHostKeyChecking accept-new" >> ~/.ssh/config |
| 203 | +
|
| 204 | + git remote set-url origin ssh://aur@aur.archlinux.org/soar-bin.git |
| 205 | + git config user.name "$GIT_USERNAME" |
| 206 | + git config user.email "$GIT_EMAIL" |
| 207 | + git add PKGBUILD .SRCINFO |
| 208 | + git commit -m "Update to ${{ steps.version.outputs.version }}" |
| 209 | + git push |
| 210 | +
|
| 211 | + update-soar-nightly-bin: |
| 212 | + name: Update soar-nightly-bin |
| 213 | + runs-on: ubuntu-latest |
| 214 | + if: >- |
| 215 | + (github.event_name == 'workflow_dispatch' && |
| 216 | + (github.event.inputs.package == 'soar-nightly-bin')) |
| 217 | + || |
| 218 | + (github.event_name == 'workflow_run' && |
| 219 | + github.event.workflow_run.conclusion == 'success' && |
| 220 | + github.event.workflow_run.name == 'soar nightly') |
| 221 | + steps: |
| 222 | + - name: Checkout |
| 223 | + uses: actions/checkout@v5 |
| 224 | + |
| 225 | + - name: Get nightly version |
| 226 | + id: version |
| 227 | + run: | |
| 228 | + if [ "${{ github.event_name }}" = "workflow_run" ]; then |
| 229 | + SHORT_SHA=$(echo "${{ github.event.workflow_run.head_sha }}" | cut -c1-7) |
| 230 | + else |
| 231 | + SHORT_SHA=$(git rev-parse --short HEAD) |
| 232 | + fi |
| 233 | + echo "version=$SHORT_SHA" >> "$GITHUB_OUTPUT" |
| 234 | + echo "Detected nightly version: $SHORT_SHA" |
| 235 | +
|
| 236 | + - name: Clone AUR package |
| 237 | + run: git clone https://aur.archlinux.org/soar-nightly-bin.git aur-soar-nightly-bin |
| 238 | + |
| 239 | + - name: Update PKGBUILD |
| 240 | + working-directory: aur-soar-nightly-bin |
| 241 | + run: | |
| 242 | + sed -i "s/^pkgver=.*/pkgver=${{ steps.version.outputs.version }}/" PKGBUILD |
| 243 | + sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD |
| 244 | +
|
| 245 | + - name: Generate .SRCINFO |
| 246 | + run: | |
| 247 | + docker run --rm -v "$PWD/aur-soar-nightly-bin:/pkg" -w /pkg archlinux:base bash -lc ' |
| 248 | + set -euo pipefail |
| 249 | + pacman -Sy --noconfirm --needed base-devel >/dev/null |
| 250 | + useradd -m build |
| 251 | + chown -R build:build /pkg |
| 252 | + su build -c "makepkg --printsrcinfo > .SRCINFO" |
| 253 | + ' |
| 254 | +
|
| 255 | + - name: Upload artifacts |
| 256 | + uses: actions/upload-artifact@v6 |
| 257 | + with: |
| 258 | + name: soar-nightly-bin-pkgbuild |
| 259 | + path: | |
| 260 | + aur-soar-nightly-bin/PKGBUILD |
| 261 | + aur-soar-nightly-bin/.SRCINFO |
| 262 | +
|
| 263 | + - name: Push to AUR |
| 264 | + if: >- |
| 265 | + (github.event_name == 'workflow_run') || |
| 266 | + (github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run == 'false') |
| 267 | + working-directory: aur-soar-nightly-bin |
| 268 | + env: |
| 269 | + AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }} |
| 270 | + GIT_USERNAME: ${{ secrets.AUR_GIT_USERNAME || 'github-actions[bot]' }} |
| 271 | + GIT_EMAIL: ${{ secrets.AUR_GIT_EMAIL || 'github-actions[bot]@users.noreply.github.com' }} |
| 272 | + run: | |
| 273 | + sudo chown -R "$(id -u):$(id -g)" . |
| 274 | +
|
| 275 | + if git diff --quiet; then |
| 276 | + echo "No changes to push." |
| 277 | + exit 0 |
| 278 | + fi |
| 279 | +
|
| 280 | + mkdir -p ~/.ssh |
| 281 | + echo "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/aur |
| 282 | + chmod 600 ~/.ssh/aur |
| 283 | + echo "Host aur.archlinux.org" >> ~/.ssh/config |
| 284 | + echo " IdentityFile ~/.ssh/aur" >> ~/.ssh/config |
| 285 | + echo " StrictHostKeyChecking accept-new" >> ~/.ssh/config |
| 286 | +
|
| 287 | + git remote set-url origin ssh://aur@aur.archlinux.org/soar-nightly-bin.git |
| 288 | + git config user.name "$GIT_USERNAME" |
| 289 | + git config user.email "$GIT_EMAIL" |
| 290 | + git add PKGBUILD .SRCINFO |
| 291 | + git commit -m "Update to nightly (${{ steps.version.outputs.version }})" |
| 292 | + git push |
0 commit comments