diff --git a/.github/workflows/aur.yml b/.github/workflows/aur.yml new file mode 100644 index 0000000..391afef --- /dev/null +++ b/.github/workflows/aur.yml @@ -0,0 +1,121 @@ +name: AUR Publish + +on: + push: + tags: + - "v*" + +permissions: + contents: read + +jobs: + publish-aur: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Derive version and checksum + id: meta + shell: bash + run: | + set -euo pipefail + PKGVER="${GITHUB_REF_NAME#v}" + SRC_URL="https://github.com/dexoron/dcr/archive/refs/tags/v${PKGVER}.tar.gz" + SHA256="$(curl -fsSL "$SRC_URL" | sha256sum | awk '{print $1}')" + + echo "pkgver=$PKGVER" >> "$GITHUB_OUTPUT" + echo "source_url=$SRC_URL" >> "$GITHUB_OUTPUT" + echo "sha256=$SHA256" >> "$GITHUB_OUTPUT" + + - name: Render AUR metadata + shell: bash + run: | + set -euo pipefail + PKGVER='${{ steps.meta.outputs.pkgver }}' + SRC_URL='${{ steps.meta.outputs.source_url }}' + SHA256='${{ steps.meta.outputs.sha256 }}' + + cat > packaging/aur/dcr/PKGBUILD < packaging/aur/dcr/.SRCINFO < ~/.ssh/aur + chmod 600 ~/.ssh/aur + ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts + + export GIT_SSH_COMMAND='ssh -i ~/.ssh/aur -o IdentitiesOnly=yes' + git clone "ssh://aur@aur.archlinux.org/${AUR_PACKAGE}.git" aur-repo + cp packaging/aur/dcr/PKGBUILD aur-repo/PKGBUILD + cp packaging/aur/dcr/.SRCINFO aur-repo/.SRCINFO + + cd aur-repo + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + if git diff --quiet; then + echo "No AUR changes" + exit 0 + fi + + git add PKGBUILD .SRCINFO + git commit -m "dcr ${{ steps.meta.outputs.pkgver }}" + git push diff --git a/packaging/aur/README.md b/packaging/aur/README.md new file mode 100644 index 0000000..a54abf5 --- /dev/null +++ b/packaging/aur/README.md @@ -0,0 +1,21 @@ +# AUR publishing + +This repository includes an automated AUR publish workflow: +- package files: `packaging/aur/dcr/PKGBUILD`, `packaging/aur/dcr/.SRCINFO` +- workflow: `.github/workflows/aur.yml` + +## One-time setup + +1. Create the `dcr` package on AUR and initialize its git repository. +2. Create an SSH key pair for CI. +3. Add the public key to your AUR account. +4. Add the private key to GitHub Actions secret `AUR_SSH_PRIVATE_KEY`. + +## Release flow + +1. Bump project version in `Cargo.toml`. +2. Push tag `v` (example: `v0.2.2`). +3. GitHub Actions will: +- compute source tarball SHA256 +- render `PKGBUILD` and `.SRCINFO` +- push updates to `ssh://aur@aur.archlinux.org/dcr.git` diff --git a/packaging/aur/dcr/.SRCINFO b/packaging/aur/dcr/.SRCINFO new file mode 100644 index 0000000..ae24466 --- /dev/null +++ b/packaging/aur/dcr/.SRCINFO @@ -0,0 +1,16 @@ +pkgbase = dcr + pkgdesc = Cargo-like utility to manage C/C++ projects + pkgver = 0.2.1 + pkgrel = 1 + url = https://github.com/dexoron/dcr + arch = x86_64 + arch = aarch64 + license = MIT + makedepends = cargo + depends = gcc-libs + optdepends = gcc: build C/C++ projects with GCC + optdepends = clang: build C/C++ projects with Clang + source = dcr-0.2.1.tar.gz::https://github.com/dexoron/dcr/archive/refs/tags/v0.2.1.tar.gz + sha256sums = 30e334fa98cd51073c0fa84c80a982584b00156b57084311ad53419441ce6235 + +pkgname = dcr diff --git a/packaging/aur/dcr/PKGBUILD b/packaging/aur/dcr/PKGBUILD new file mode 100644 index 0000000..f1fe2dd --- /dev/null +++ b/packaging/aur/dcr/PKGBUILD @@ -0,0 +1,26 @@ +pkgname=dcr +pkgver=0.2.1 +pkgrel=1 +pkgdesc="Cargo-like utility to manage C/C++ projects" +arch=('x86_64' 'aarch64') +url="https://github.com/dexoron/dcr" +license=('MIT') +depends=('gcc-libs') +makedepends=('cargo') +optdepends=( + 'gcc: build C/C++ projects with GCC' + 'clang: build C/C++ projects with Clang' +) +source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz") +sha256sums=('30e334fa98cd51073c0fa84c80a982584b00156b57084311ad53419441ce6235') + +build() { + cd "$srcdir/$pkgname-$pkgver" + cargo build --release --locked +} + +package() { + cd "$srcdir/$pkgname-$pkgver" + install -Dm755 "target/release/dcr" "$pkgdir/usr/bin/dcr" + install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +}