diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 42e412d..694f280 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -237,7 +237,7 @@ jobs: run: | set -euo pipefail version="${GITHUB_REF_NAME#v}" - pkgver="${version//-/_}" + pkgver="${version//-/}" bash dist/arch/build-pkg.sh \ "target/${{ matrix.target }}/release/tsng" \ "${{ matrix.pkg_arch }}" \ @@ -252,7 +252,7 @@ jobs: run: | set -euo pipefail version="${GITHUB_REF_NAME#v}" - pkgver="${version//-/_}" + pkgver="${version//-/}" tray="target/${{ matrix.gnu_target }}/release/tsunagi-tray" bash dist/deb/build-deb.sh \ "target/${{ matrix.target }}/release/tsng" \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5aa157c..17ff8f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -239,7 +239,7 @@ jobs: run: | set -euo pipefail version="${GITHUB_REF_NAME#v}" - pkgver="${version//-/_}" + pkgver="${version//-/}" bash dist/arch/build-pkg.sh \ "target/${{ matrix.target }}/release/tsng" \ "${{ matrix.pkg_arch }}" \ @@ -254,7 +254,7 @@ jobs: run: | set -euo pipefail version="${GITHUB_REF_NAME#v}" - pkgver="${version//-/_}" + pkgver="${version//-/}" tray="target/${{ matrix.gnu_target }}/release/tsunagi-tray" bash dist/deb/build-deb.sh \ "target/${{ matrix.target }}/release/tsng" \ @@ -320,3 +320,25 @@ jobs: --verify-tag \ "${prerelease[@]}" fi + + notify-arch-repository: + name: Publish packages to the Arch repository + needs: publish + if: ${{ github.server_url == 'https://github.com' }} + runs-on: ubuntu-latest + permissions: {} + steps: + - name: Notify arch_repo of the completed release + shell: bash + env: + GH_TOKEN: ${{ secrets.ARCH_REPO_TOKEN }} + RELEASE_TAG: ${{ github.ref_name }} + run: | + set -euo pipefail + if [[ -z "$GH_TOKEN" ]]; then + echo '::error::Set the ARCH_REPO_TOKEN Actions secret with Contents: write access to house-of-vanity/arch_repo.' + exit 1 + fi + jq -n --arg repository "$GITHUB_REPOSITORY" --arg tag "$RELEASE_TAG" \ + '{event_type: "new_package", client_payload: {repository: $repository, tag: $tag}}' \ + | gh api --method POST repos/house-of-vanity/arch_repo/dispatches --input - diff --git a/dist/arch/README.md b/dist/arch/README.md index 838076e..06564b4 100644 --- a/dist/arch/README.md +++ b/dist/arch/README.md @@ -55,3 +55,37 @@ sudo pacman -R tsunagi stops and disables the service. The `tsunagi` user and `/var/lib/tsunagi` are left in place; remove them by hand if you want them gone. + +## Automatic package repository + +GitHub releases are also published to the Arch repository after all release +assets have uploaded. Add this to `/etc/pacman.conf`: + +```ini +[btwiusearch.net] +SigLevel = Optional TrustAll +Server = https://btwiusearch.net/arch_repo/$arch/ +``` + +Install with `sudo pacman -Syu tsunagi`, or `sudo pacman -Syu tsunagi-gui` for +the x86_64 desktop variant. Subsequent versions arrive through `pacman -Syu`. +Prerelease tags are included. ARM packages are provided for `aarch64` and `armv7h`. + +Maintainers must set the `ARCH_REPO_TOKEN` Actions secret to a fine-grained token +with **Contents: Read and write** permission on `house-of-vanity/arch_repo` only. +The separate notification job fails clearly if the secret is missing; the built +release remains available. Once the secret is configured, rerun the failed job. +A successful notification schedules publication; check the +[Arch repository workflow](https://github.com/house-of-vanity/arch_repo/actions/workflows/update_repo.yaml) +for the deployment result. A manual run there can import an existing tag without +rebuilding it. Repository setup and recovery are documented in +[arch_repo](https://github.com/house-of-vanity/arch_repo#github-setup). + +Arch package versions use epoch `1` and spell prereleases as `0.1.0rc.33`, so +pacman upgrades correctly from RC to stable. The epoch also migrates packages +installed using the former `0.1.0_rc.33` spelling. It appears in pacman's version +metadata, not in archive filenames. This does not change the Git tag or the +application's version string. + +Package/version checks can be run on Arch Linux with `python`, `libarchive`, and +`zstd` installed: `bash dist/arch/test-pkg.sh`. diff --git a/dist/arch/build-pkg.sh b/dist/arch/build-pkg.sh index 4094f59..5ab9c4e 100755 --- a/dist/arch/build-pkg.sh +++ b/dist/arch/build-pkg.sh @@ -24,10 +24,13 @@ here="$(cd "$(dirname "$0")" && pwd)" root="$(mktemp -d)" trap 'rm -rf "$root"' EXIT -# pacman pkgver may not contain '-', so a prerelease tag like 0.1.0-rc.9 becomes -# 0.1.0_rc.9. -pkgver="$(printf '%s' "$version" | tr '-' '_')" +# Attach the prerelease suffix directly: vercmp orders 0.1.0rc.9 < 0.1.0, +# whereas the old 0.1.0_rc.9 spelling sorts ABOVE the stable release. Epoch 1 +# ensures existing installations can upgrade from the old spelling as well. +# The epoch is metadata only; it does not appear in package filenames. +pkgver="$(printf '%s' "$version" | tr -d '-')" pkgrel=1 +epoch=1 # Payload. Arch keeps units under /usr/lib/systemd/system and installs to # /usr/bin, so the service's ExecStart is rewritten to match. @@ -67,7 +70,7 @@ size="$(du -sb "$root" | cut -f1)" cat > "$root/.PKGINFO" < "$work/pkginfo" + grep -qx "pkgver = 1:${pkgver}-1" "$work/pkginfo" + grep -qx 'pkgname = tsunagi' "$work/pkginfo" + bsdtar -tf "$output" | grep -qx 'usr/bin/tsng' +done + +test "$(vercmp 1:0.1.0rc.9-1 0.1.0_rc.99-1)" -gt 0 +test "$(vercmp 1:0.1.0rc.10-1 1:0.1.0rc.9-1)" -gt 0 +test "$(vercmp 1:0.1.0-1 1:0.1.0rc.10-1)" -gt 0 + +output="$work/tsunagi-gui-0.1.0rc.10-1-x86_64.pkg.tar.zst" +bash "$here/build-pkg.sh" /usr/bin/true x86_64 0.1.0-rc.10 "$output" /usr/bin/true +bsdtar -xOf "$output" .PKGINFO > "$work/pkginfo" +grep -qx 'pkgname = tsunagi-gui' "$work/pkginfo" +grep -qx 'pkgver = 1:0.1.0rc.10-1' "$work/pkginfo" +grep -qx 'conflict = tsunagi' "$work/pkginfo" +bsdtar -tf "$output" | grep -qx 'usr/bin/tsunagi-tray' +echo 'Arch packaging and version-order checks passed'