From 208c81899addbe1bf3ccb183ff207b9edb004b03 Mon Sep 17 00:00:00 2001 From: abrown38 Date: Wed, 30 Sep 2026 20:01:10 +0000 Subject: [PATCH] debian repo --- .gitea/workflows/release.yaml | 27 ++++++++++++++++++++++++++- README.md | 16 ++++++++++++++-- docs/guide.md | 19 ++++++++++++++++--- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 38990c4..5076e88 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -27,7 +27,7 @@ jobs: run: | SUDO=$(command -v sudo || true) $SUDO apt-get update -qq - $SUDO apt-get install -y -qq make python3 dpkg shellcheck python3-pyflakes + $SUDO apt-get install -y -qq make python3 dpkg curl shellcheck python3-pyflakes - name: Build (make check runs first) run: make deb @@ -39,3 +39,28 @@ jobs: # The job's own token; set a RELEASE_TOKEN secret instead if it isn't allowed to write releases GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITEA_TOKEN }} run: python3 packaging/gitea-release.py "$GITHUB_REF_NAME" build/*.deb + + # Gitea's Debian registry, as an apt repository: + # deb /api/packages//debian stable main + - name: Publish to the apt repository + env: + POOL: ${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/debian/pool/stable/main + # The job's own token; set a PACKAGE_TOKEN secret (scope write:package) if it isn't allowed to + TOKEN: ${{ secrets.PACKAGE_TOKEN || secrets.GITEA_TOKEN }} + run: | + deb=$(echo build/*.deb) + upload() { + curl -sS -o response.txt -w '%{http_code}' --user "$GITHUB_ACTOR:$TOKEN" \ + --upload-file "$deb" "$POOL/upload" + } + status=$(upload) + if [ "$status" = 409 ]; then + # This version is there already (the tag was pushed again): replace it + curl -sS -f --user "$GITHUB_ACTOR:$TOKEN" -X DELETE \ + "$POOL/terraria-server-manager/$(cat VERSION)/all" + status=$(upload) + fi + if [ "$status" != 201 ]; then + echo "upload failed: HTTP $status"; cat response.txt; echo; exit 1 + fi + echo "published $(basename "$deb") to $POOL" diff --git a/README.md b/README.md index da60c8b..fac9325 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,19 @@ sudo terractl attach calamity ## Install -Download the `.deb` from the releases page, then: +From the apt repository, which also brings updates with `sudo apt upgrade`: + +```bash +sudo install -d -m 0755 /etc/apt/keyrings +sudo curl -fsSL https://gitea.adbraun.lol/api/packages/adam/debian/repository.key \ + -o /etc/apt/keyrings/terraria-server-manager.asc +echo "deb [signed-by=/etc/apt/keyrings/terraria-server-manager.asc] https://gitea.adbraun.lol/api/packages/adam/debian stable main" | + sudo tee /etc/apt/sources.list.d/terraria-server-manager.list +sudo apt update +sudo apt install terraria-server-manager +``` + +Or download the `.deb` from the releases page, then: ```bash sudo apt install ./terraria-server-manager__all.deb @@ -75,7 +87,7 @@ To release, update `VERSION` and `CHANGELOG.md`, commit, and push a matching tag git tag v$(cat VERSION) && git push origin v$(cat VERSION) ``` -The `release` workflow (`.gitea/workflows/release.yaml`, Gitea Actions) then builds the `.deb` and publishes it as a release, with that version's changelog section as the notes. It needs a runner with the `ubuntu-latest` label. To build a package by hand instead, run `make deb`. +The `release` workflow (`.gitea/workflows/release.yaml`, Gitea Actions) then builds the `.deb`, publishes it as a release with that version's changelog section as the notes, and adds it to the apt repository. It needs a runner with the `ubuntu-latest` label. To build a package by hand instead, run `make deb`. ## Disclaimer diff --git a/docs/guide.md b/docs/guide.md index 1d40ea7..f7281f3 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -100,13 +100,25 @@ The server can write only inside `instances/`. It reads `dist/` but can never ch ## Installation -The package works on Debian 12 or newer and Ubuntu 22.04 or newer. +The package works on Debian 12 or newer and Ubuntu 22.04 or newer. The easiest way is the apt repository, since `sudo apt upgrade` then keeps it up to date: + +```bash +sudo install -d -m 0755 /etc/apt/keyrings +sudo curl -fsSL https://gitea.adbraun.lol/api/packages/adam/debian/repository.key \ + -o /etc/apt/keyrings/terraria-server-manager.asc +echo "deb [signed-by=/etc/apt/keyrings/terraria-server-manager.asc] https://gitea.adbraun.lol/api/packages/adam/debian stable main" | + sudo tee /etc/apt/sources.list.d/terraria-server-manager.list +sudo apt update +sudo apt install terraria-server-manager +``` + +The repository is signed; the first two commands fetch its key and let apt trust it for this repository only. Alternatively, download a `.deb` from the releases page and install it directly: ```bash sudo apt install ./terraria-server-manager_0.0.9_all.deb ``` -Using `apt install ./file.deb` (rather than `dpkg -i`) installs the dependencies automatically. `unzip` is required. `curl` and the ICU library are "recommended", which apt installs by default; they're only needed for tModLoader instances, which crash with `Aborted` without ICU. `polkitd` is also recommended: it lets members of the `terraria` group start and stop servers without `sudo` (see [Permissions](#permissions)). +Using `apt install` (rather than `dpkg -i`) installs the dependencies automatically. `unzip` is required. `curl` and the ICU library are "recommended", which apt installs by default; they're only needed for tModLoader instances, which crash with `Aborted` without ICU. `polkitd` is also recommended: it lets members of the `terraria` group start and stop servers without `sudo` (see [Permissions](#permissions)). Installing the package: @@ -125,7 +137,8 @@ sudo ufw allow 7777/tcp # example with ufw ### Upgrading the package ```bash -sudo apt install ./terraria-server-manager__all.deb +sudo apt update && sudo apt upgrade # from the apt repository +sudo apt install ./terraria-server-manager__all.deb # or from a downloaded .deb ``` Running servers are not restarted. Each one picks up the new version the next time it starts. Your changes to `/etc/default/terractl` are kept; if the new package also changes that file, dpkg asks which version to keep.