Gate the sccache install to the ephemeral x86_64 container; on the bare klokka runner check-and-fail (the tarball was x86_64-only, so it was a host mutation and a wrong-arch binary). Switch checkout to v4 builtin:checkout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
178 lines
7.2 KiB
YAML
178 lines
7.2 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
build:
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- arch: x86_64
|
|
target: x86_64-unknown-linux-gnu
|
|
runs-on: ubuntu-latest
|
|
sccache_dir: /sccache
|
|
- arch: aarch64
|
|
target: aarch64-unknown-linux-gnu
|
|
runs-on: aarch64
|
|
sccache_dir: /var/lib/gitea-runner/sccache
|
|
|
|
runs-on: ${{ matrix.runs-on }}
|
|
|
|
steps:
|
|
- uses: builtin:checkout
|
|
|
|
- name: Install Rust stable
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Set up sccache
|
|
run: |
|
|
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
|
|
echo "SCCACHE_DIR=${{ matrix.sccache_dir }}" >> "$GITHUB_ENV"
|
|
mkdir -p "${{ matrix.sccache_dir }}"
|
|
if command -v sccache >/dev/null 2>&1; then sccache --version; exit 0; fi
|
|
# Bare runners (aarch64 = klokka host) are pre-provisioned; CI must not
|
|
# install onto them (and this tarball is x86_64-only). Only the
|
|
# ephemeral x86_64 container installs; a bare host missing it fails loud.
|
|
if [ "${{ matrix.arch }}" != x86_64 ]; then
|
|
echo "::error::sccache missing on the bare ${{ matrix.arch }} runner — provision klokka; CI must not install on bare hosts"; exit 1
|
|
fi
|
|
V=0.8.2
|
|
curl -sSL "https://github.com/mozilla/sccache/releases/download/v${V}/sccache-v${V}-x86_64-unknown-linux-musl.tar.gz" | tar -xz
|
|
sudo install -m0755 "sccache-v${V}-x86_64-unknown-linux-musl/sccache" /usr/local/bin/sccache
|
|
sccache --version
|
|
|
|
- name: Ensure build deps (libpipewire + clang for bindgen, C++ for ssstretch)
|
|
run: |
|
|
if command -v apt-get >/dev/null; then
|
|
# Ephemeral container runner: safe to install into it.
|
|
SUDO=""; command -v sudo >/dev/null && SUDO=sudo
|
|
$SUDO apt-get update
|
|
$SUDO apt-get install -y libpipewire-0.3-dev libspa-0.2-dev clang libclang-dev build-essential pkg-config
|
|
else
|
|
# Bare/host runner: never mutate it - require deps preinstalled.
|
|
missing=""
|
|
pkg-config --exists libpipewire-0.3 2>/dev/null || missing="$missing libpipewire(+dev headers)"
|
|
command -v clang >/dev/null || missing="$missing clang"
|
|
command -v c++ >/dev/null || command -v g++ >/dev/null || missing="$missing c++"
|
|
if [ -n "$missing" ]; then
|
|
echo "::error::bare runner missing build deps:$missing — install once on the host; CI does not modify bare runners"
|
|
exit 1
|
|
fi
|
|
echo "bare runner already has libpipewire + clang + a C++ compiler"
|
|
fi
|
|
|
|
- name: Test
|
|
run: cargo test --release --locked --target ${{ matrix.target }}
|
|
|
|
- name: Build
|
|
run: cargo build --release --locked --target ${{ matrix.target }}
|
|
|
|
- name: Package
|
|
run: |
|
|
TAG=${{ gitea.ref_name }}
|
|
TARBALL="djdeck-${TAG}-${{ matrix.arch }}.tar.gz"
|
|
mkdir pkg
|
|
cp target/${{ matrix.target }}/release/djdeck pkg/
|
|
cp LICENSE pkg/
|
|
tar -czf "${TARBALL}" -C pkg .
|
|
sha256sum "${TARBALL}" > "${TARBALL}.sha256"
|
|
echo "TARBALL=${TARBALL}" >> $GITHUB_ENV
|
|
|
|
- name: Create release
|
|
run: |
|
|
curl -sX POST \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" \
|
|
-d "{\"tag_name\":\"${{ gitea.ref_name }}\",\"name\":\"${{ gitea.ref_name }}\"}" \
|
|
--fail-with-body || true
|
|
|
|
- name: Upload assets
|
|
run: |
|
|
RELEASE_ID=$(curl -s \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/tags/${{ gitea.ref_name }}" \
|
|
| jq -r '.id')
|
|
|
|
for FILE in "${{ env.TARBALL }}" "${{ env.TARBALL }}.sha256"; do
|
|
EXISTING=$(curl -s \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets" \
|
|
| jq -r ".[] | select(.name == \"${FILE}\") | .id")
|
|
for AID in $EXISTING; do
|
|
curl -sX DELETE \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets/${AID}"
|
|
done
|
|
|
|
curl -sX POST \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
"${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets?name=${FILE}" \
|
|
--data-binary "@${FILE}" --fail-with-body
|
|
done
|
|
|
|
update-aur:
|
|
needs: build
|
|
runs-on: aarch64
|
|
|
|
steps:
|
|
- uses: builtin:checkout
|
|
|
|
- name: Compute checksums and update PKGBUILD
|
|
run: |
|
|
TAG=${{ gitea.ref_name }}
|
|
BASE="${{ gitea.server_url }}/${{ gitea.repository }}/releases/download/${TAG}"
|
|
SUM_X86=$(curl -sL "${BASE}/djdeck-${TAG}-x86_64.tar.gz" | sha256sum | cut -d' ' -f1)
|
|
SUM_AARCH=$(curl -sL "${BASE}/djdeck-${TAG}-aarch64.tar.gz" | sha256sum | cut -d' ' -f1)
|
|
sed -i "s/sha256sums_x86_64=('.*')/sha256sums_x86_64=('${SUM_X86}')/" aur/PKGBUILD
|
|
sed -i "s/sha256sums_aarch64=('.*')/sha256sums_aarch64=('${SUM_AARCH}')/" aur/PKGBUILD
|
|
|
|
- name: Publish to the Arch package registry
|
|
continue-on-error: true
|
|
run: |
|
|
set -euo pipefail
|
|
if [ -z "${{ secrets.REGISTRY_TOKEN }}" ]; then
|
|
echo "::warning::REGISTRY_TOKEN not set — skipping Arch registry publish"
|
|
exit 0
|
|
fi
|
|
cd aur
|
|
for carch in aarch64 x86_64; do
|
|
pkgfile=$(CARCH="$carch" makepkg --packagelist | tail -1)
|
|
CARCH="$carch" makepkg -f --nodeps --noconfirm --skipinteg
|
|
curl --fail-with-body --user "bl:${{ secrets.REGISTRY_TOKEN }}" \
|
|
--upload-file "$pkgfile" \
|
|
"${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/arch/uhhm"
|
|
done
|
|
|
|
- name: Push to AUR
|
|
env:
|
|
AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
|
|
run: |
|
|
install -dm700 ~/.ssh
|
|
echo "$AUR_SSH_KEY" > ~/.ssh/aur
|
|
chmod 600 ~/.ssh/aur
|
|
echo "Host aur.archlinux.org" >> ~/.ssh/config
|
|
echo " IdentityFile ~/.ssh/aur" >> ~/.ssh/config
|
|
echo " User aur" >> ~/.ssh/config
|
|
ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
rm -rf /tmp/aur-djdeck
|
|
git clone ssh://aur@aur.archlinux.org/djdeck.git /tmp/aur-djdeck
|
|
cp aur/PKGBUILD /tmp/aur-djdeck/
|
|
cd /tmp/aur-djdeck
|
|
makepkg --printsrcinfo > .SRCINFO
|
|
git config user.name "Bendik Aagaard Lynghaug"
|
|
git config user.email "bendik.lynghaug@gmail.com"
|
|
git add PKGBUILD .SRCINFO
|
|
git commit -m "Update to ${{ gitea.ref_name }}"
|
|
git push origin master
|