name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build-and-release:
name: Build and Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Resolve tag and version
id: version
run: |
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
TAG="$GITHUB_REF_NAME"
else
TAG="$(git tag --list 'v*' --sort=-v:refname | head -n1)"
if [[ -z "$TAG" ]]; then
echo "::error::No v* tags found"
exit 1
fi
fi
VER="${TAG#v}"
if [[ ! "$VER" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Version '${VER}' is not valid semver"
exit 1
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${VER}" >> "$GITHUB_OUTPUT"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Build release binary
run: cargo build --release --locked
env:
CARGO_TARGET_DIR: target
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
files: target/release/larpshell
generate_release_notes: true
fail_on_unmatched_files: true
aur-publish:
name: Publish to AUR
needs: build-and-release
runs-on: ubuntu-latest
container: archlinux:base-devel
permissions:
contents: write
steps:
- name: Install dependencies
run: pacman -Syu --noconfirm git openssh pacman-contrib
- name: Checkout
uses: actions/checkout@v6
with:
ref: mommy
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup AUR SSH
env:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
run: |
AUR_KEY=/tmp/aur_ssh_key
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$AUR_KEY"
chmod 600 "$AUR_KEY"
echo "GIT_SSH_COMMAND=ssh -i ${AUR_KEY} -o StrictHostKeyChecking=accept-new" >> "$GITHUB_ENV"
ssh -i "$AUR_KEY" -o StrictHostKeyChecking=accept-new -T aur@aur.archlinux.org 2>&1 || true
- name: Setup non-root user
run: |
useradd -m builder
echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
chown -R builder:builder .
- name: Update larpshell PKGBUILD
env:
VER: ${{ needs.build-and-release.outputs.version }}
run: |
cd aur/larpshell
sed -i "s/^pkgver=.*/pkgver=${VER}/" PKGBUILD
sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD
chown builder:builder PKGBUILD
su builder -c "updpkgsums"
su builder -c "makepkg --printsrcinfo > .SRCINFO"
echo "=== Updated PKGBUILD ==="
grep -E '^(pkgver|pkgrel|sha256sums)=' PKGBUILD
- name: Update larpshell-git PKGBUILD and .SRCINFO
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
GITVER="r$(git rev-list --count HEAD).$(git rev-parse --short HEAD)"
cd aur/larpshell-git
sed -i "s/^pkgver=.*/pkgver=${GITVER}/" PKGBUILD
chown builder:builder PKGBUILD
su builder -c "makepkg --printsrcinfo > .SRCINFO"
- name: Publish larpshell to AUR
env:
AUR_USERNAME: ${{ secrets.AUR_USERNAME }}
AUR_EMAIL: ${{ secrets.AUR_EMAIL }}
VER: ${{ needs.build-and-release.outputs.version }}
run: |
git clone --depth 1 ssh://aur@aur.archlinux.org/larpshell.git /tmp/aur-larpshell
cp aur/larpshell/PKGBUILD /tmp/aur-larpshell/PKGBUILD
cp aur/larpshell/.SRCINFO /tmp/aur-larpshell/.SRCINFO
cd /tmp/aur-larpshell
git config user.name "$AUR_USERNAME"
git config user.email "$AUR_EMAIL"
git add PKGBUILD .SRCINFO
git diff --cached --quiet && echo "No changes to push" || {
git commit -m "upgpkg: larpshell ${VER}"
git push origin master
}
- name: Publish larpshell-git to AUR
env:
AUR_USERNAME: ${{ secrets.AUR_USERNAME }}
AUR_EMAIL: ${{ secrets.AUR_EMAIL }}
run: |
git clone --depth 1 ssh://aur@aur.archlinux.org/larpshell-git.git /tmp/aur-larpshell-git
cp aur/larpshell-git/PKGBUILD /tmp/aur-larpshell-git/PKGBUILD
cp aur/larpshell-git/.SRCINFO /tmp/aur-larpshell-git/.SRCINFO
cd /tmp/aur-larpshell-git
git config user.name "$AUR_USERNAME"
git config user.email "$AUR_EMAIL"
git add PKGBUILD .SRCINFO
git diff --cached --quiet && echo "No changes to push" || {
git commit -m "update: larpshell-git PKGBUILD"
git push origin master
}
- name: Commit updated AUR files to repo
env:
VER: ${{ needs.build-and-release.outputs.version }}
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add aur/larpshell/PKGBUILD aur/larpshell/.SRCINFO aur/larpshell-git/PKGBUILD aur/larpshell-git/.SRCINFO
git diff --cached --quiet && echo "No changes to commit" || {
git commit -m "chore(aur): update packages for ${VER}"
git push origin mommy
}