name: Publish to AUR
on:
push:
tags: ["v*.*.*"]
workflow_dispatch:
inputs:
tag:
description: "Tag to publish (e.g. v0.1.3)"
required: true
type: string
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- pkgname: wdotool
pkgbuild_dir: packaging/aur/wdotool
asset_path: archive/refs/tags/TAG.tar.gz
wait_for_asset: false
- pkgname: wdotool-bin
pkgbuild_dir: packaging/aur/wdotool-bin
asset_path: releases/download/TAG/wdotool-x86_64-unknown-linux-gnu.tar.xz
wait_for_asset: true
steps:
- name: Check out source (main)
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Extract version
id: version
run: |
tag="${{ inputs.tag || github.ref_name }}"
pkgver="${tag#v}"
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
echo "pkgver=${pkgver}" >> "$GITHUB_OUTPUT"
- name: Wait for + hash release asset
id: sha
env:
REPO: ${{ github.repository }}
TAG: ${{ steps.version.outputs.tag }}
ASSET_TEMPLATE: ${{ matrix.asset_path }}
WAIT: ${{ matrix.wait_for_asset }}
run: |
set -euo pipefail
url="https://github.com/${REPO}/${ASSET_TEMPLATE//TAG/${TAG}}"
echo "Fetching: ${url}"
# For wdotool-bin, poll the URL until the Release workflow has
# uploaded the asset. 15 min timeout (cargo-dist builds typically
# finish in 3–5 min).
if [ "${WAIT}" = "true" ]; then
tries=0
until curl -fsSL "${url}" -o asset.bin; do
tries=$((tries + 1))
if [ ${tries} -ge 45 ]; then
echo "::error::Asset at ${url} still 404 after 15 minutes"
exit 1
fi
echo "(${tries}/45) asset not ready yet; sleeping 20s"
sleep 20
done
else
curl -fsSL "${url}" -o asset.bin
fi
sum="$(sha256sum asset.bin | awk '{print $1}')"
echo "sha256=${sum}" >> "$GITHUB_OUTPUT"
- name: Patch PKGBUILD
env:
PKGBUILD: ${{ matrix.pkgbuild_dir }}/PKGBUILD
V: ${{ steps.version.outputs.pkgver }}
SHA: ${{ steps.sha.outputs.sha256 }}
run: |
sed -i "s|^pkgver=.*|pkgver=${V}|" "${PKGBUILD}"
sed -i "s|^pkgrel=.*|pkgrel=1|" "${PKGBUILD}"
sed -i "s|^sha256sums=.*|sha256sums=('${SHA}')|" "${PKGBUILD}"
echo "--- patched ${PKGBUILD} ---"
cat "${PKGBUILD}"
- name: Publish to AUR
uses: KSXGitHub/github-actions-deploy-aur@v4.1.3
with:
pkgname: ${{ matrix.pkgname }}
pkgbuild: ${{ matrix.pkgbuild_dir }}/PKGBUILD
commit_username: Matthew Cushing
commit_email: hgxtymphwn@privaterelay.appleid.com
ssh_private_key: ${{ secrets.AUR_SSH_KEY }}
commit_message: "Update to ${{ steps.version.outputs.pkgver }}"
ssh_keyscan_types: rsa,ecdsa,ed25519
- name: Sync updated PKGBUILD back to main
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "AUR: bump ${{ matrix.pkgname }} to ${{ steps.version.outputs.pkgver }}"
file_pattern: ${{ matrix.pkgbuild_dir }}/PKGBUILD
commit_user_name: Matthew Cushing
commit_user_email: hgxtymphwn@privaterelay.appleid.com
branch: main