diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a66e33..a1e2b9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ One section per version, newest first. +## v0.4.0 (2026-11-04) + +### Features + +- The queue survives a restart, a crash or SteamOS closing the app. It comes back paused on the same track, at most 15 seconds before where it was, and the server hears nothing until play is pressed. Each server keeps its own saved queue. +- Each release on Gitea has the Flatpak bundle attached, so installing on a Steam machine no longer needs a local build. + +### Bug fixes + +- A track that cannot be played is skipped on its own. Before, it could skip the next track too, or stop the queue. +- Play pressed while a track is still loading is no longer ignored. + ## v0.3.0 (2026-11-04) ### Features diff --git a/Cargo.lock b/Cargo.lock index 28351bd..16b3b3c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4385,7 +4385,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "remus" -version = "0.3.0" +version = "0.4.0" dependencies = [ "anyhow", "directories", diff --git a/Cargo.toml b/Cargo.toml index 5eef3f3..236793d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "remus" -version = "0.3.0" +version = "0.4.0" edition = "2024" license = "MIT" diff --git a/Makefile b/Makefile index 65deb96..af797a6 100644 --- a/Makefile +++ b/Makefile @@ -187,6 +187,19 @@ bump: git tag -a "v$$new" -m "v$$new"; \ echo "$$current -> $$new, tagged v$$new on $$(git rev-parse --short HEAD) ($$(git log -1 --format=%s))" +# Publishing. Builds the bundle for the version tagged on HEAD and attaches it +# to a new Gitea release, with the changelog entry as its notes. +GITEA_URL ?= https://gitea.anshorei.me +GITEA_REPO ?= Fettleshed/Remus +GITEA_REMOTE ?= origin +GITEA_TOKEN_FILE ?= $(HOME)/.config/gitea/token + +.PHONY: publish +publish: ## Release the tagged version on Gitea with the Flatpak bundle attached + @VERSION="$(CURRENT)" GITEA_URL="$(GITEA_URL)" GITEA_REPO="$(GITEA_REPO)" \ + GITEA_REMOTE="$(GITEA_REMOTE)" GITEA_TOKEN_FILE="$(GITEA_TOKEN_FILE)" \ + bash scripts/publish.sh + .PHONY: clean clean: ## Remove build output, screenshots and scratch config cargo clean diff --git a/README.md b/README.md index ddc5271..3ee4a14 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Preferences live apart from the login, in `~/.config/remus/settings.toml`, so lo ## Install on SteamOS -Build the bundle on any Linux machine with Flatpak: +A published version has `remus-.flatpak` attached to its release on Gitea (see [Versions](#versions)). Download that, or build the bundle on any Linux machine with Flatpak: ``` make flatpak-bundle # writes target/flatpak/remus.flatpak @@ -37,13 +37,13 @@ make flatpak-bundle # writes target/flatpak/remus.flatpak On the Steam machine, in Desktop Mode: -1. Copy `remus.flatpak` over and install it from a terminal: `flatpak install --user remus.flatpak`. Flatpak pulls the freedesktop 26.08 runtime from Flathub. +1. Copy the bundle over and install it from a terminal: `flatpak install --user remus.flatpak`. Flatpak pulls the freedesktop 26.08 runtime from Flathub. 2. In Steam, choose Games → Add a Non-Steam Game to My Library and pick Remus. 3. Back in Game Mode, open its controller settings and pick a Gamepad layout, so Steam passes the buttons through as a controller and not as keyboard and mouse. The Flatpak keeps its login and cover cache in `~/.var/app/me.anshorei.Fettleshed.Remus/`, not in `~/.config` and `~/.cache`. Flatpak sets `XDG_CONFIG_HOME` itself there, so overriding it with `flatpak run --env` has no effect. -To update, build a new bundle and install it the same way. +A bundle does not update itself. To update, install the next version's bundle the same way. ## Controls @@ -92,3 +92,18 @@ Every finished ticket bumps the version, so a build on the Deck can be matched t - Before bumping, add a `## v ()` entry at the top of `CHANGELOG.md`, with `### Features` and `### Bug fixes` subsections (leave out an empty one), and commit it with the change. `make version` prints the current version. - Bump on local `master` only: fast-forward `master` to the finished work, switch to it, then bump. The targets refuse any other branch. - The bump writes the new version to `Cargo.toml`, `Cargo.lock` and the Flatpak metainfo, amends that into the last commit and tags it `v`. It refuses a dirty tree, a commit that is already tagged or pushed, and a version the changelog has no entry for. + +To release a version once it is bumped: + +1. `git push --follow-tags origin master` +2. `make publish` + +`make publish` builds the Flatpak bundle for the version tagged on HEAD and creates its Gitea release. The release has the tag as its title and the changelog entry as its notes, and `remus-.flatpak` is attached. It needs a Gitea token with `write:repository`, from `GITEA_TOKEN` or the file `~/.config/gitea/token` (`GITEA_TOKEN_FILE` to put it elsewhere). It checks everything before the build and refuses when: + +- the tree is dirty +- HEAD is not tagged with the version in `Cargo.toml` +- there is no token +- the tag is not on the remote, or the remote's tag is a different one +- the version already has a release + +If the upload fails, it deletes the release again so the next run starts clean. `GITEA_URL`, `GITEA_REPO` and `GITEA_REMOTE` default to this repository on `gitea.anshorei.me`. diff --git a/flatpak/me.anshorei.Fettleshed.Remus.metainfo.xml b/flatpak/me.anshorei.Fettleshed.Remus.metainfo.xml index eb0f34b..bd4054f 100644 --- a/flatpak/me.anshorei.Fettleshed.Remus.metainfo.xml +++ b/flatpak/me.anshorei.Fettleshed.Remus.metainfo.xml @@ -20,6 +20,7 @@ + diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 0000000..ccd5bfa --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,119 @@ +#!/usr/bin/env bash +# Publishes the tagged version on HEAD as a Gitea release with the Flatpak +# bundle attached. Run by `make publish`, after a bump and a push with tags. +# +# Every check runs before the slow Flatpak build, so a refusal costs seconds. +# +# Environment, set by the Makefile: +# VERSION version in Cargo.toml +# GITEA_URL e.g. https://gitea.anshorei.me +# GITEA_REPO owner/name, e.g. Fettleshed/Remus +# GITEA_REMOTE git remote that holds the tags +# GITEA_TOKEN or GITEA_TOKEN_FILE API token with write:repository + +set -euo pipefail + +fail() { + echo "error: $*" >&2 + exit 1 +} + +for tool in curl jq git awk; do + command -v "$tool" >/dev/null || fail "$tool is not installed" +done +[ -n "${VERSION:-}" ] || fail "no version found in the [package] table of Cargo.toml" +tag="v$VERSION" +api="${GITEA_URL%/}/api/v1/repos/$GITEA_REPO" +asset="remus-$VERSION.flatpak" + +# The bundle is built from the working tree, so it has to be the tagged commit. +if [ -n "$(git status --porcelain)" ]; then + echo "error: working tree is dirty, and the bundle would not be what $tag names:" >&2 + git status --short >&2 + exit 1 +fi +head_tags=$(git tag --points-at HEAD --list 'v*') +if ! grep -qxF "$tag" <<<"$head_tags"; then + if [ -n "$head_tags" ]; then + fail "HEAD is tagged $(paste -sd' ' <<<"$head_tags"), but Cargo.toml says $VERSION" + fi + fail "HEAD is not tagged $tag. Check out the tag, or bump first with make patch, minor or major." +fi + +# The token goes to curl in a header file, so it is never on a command line +# or in the output. +if [ -n "${GITEA_TOKEN:-}" ]; then + token=$GITEA_TOKEN +elif [ -n "${GITEA_TOKEN_FILE:-}" ] && [ -r "$GITEA_TOKEN_FILE" ]; then + token=$(tr -d '[:space:]' <"$GITEA_TOKEN_FILE") +else + fail "no Gitea token. Set GITEA_TOKEN, or put one in ${GITEA_TOKEN_FILE:-a file named by GITEA_TOKEN_FILE}. It needs write:repository." +fi +[ -n "$token" ] || fail "the Gitea token is empty" +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT +(umask 077 && printf 'Authorization: token %s\n' "$token" >"$tmp/auth") +unset token GITEA_TOKEN + +# Calls the API. Prints the body and returns the HTTP status in $status. +call() { + local method=$1 url=$2 + shift 2 + status=$(curl -sS -o "$tmp/body" -w '%{http_code}' -X "$method" -H @"$tmp/auth" "$@" "$url") || + fail "could not reach $GITEA_URL" +} + +# The local tag object has to be the one on the remote, or the release would +# point at a tag that names another commit, or at none. +remote_tag=$(git ls-remote --tags "$GITEA_REMOTE" "refs/tags/$tag" | cut -f1) || + fail "could not list the tags on $GITEA_REMOTE" +[ -n "$remote_tag" ] || fail "$tag is not on $GITEA_REMOTE yet. Push it first: git push --follow-tags $GITEA_REMOTE" +[ "$remote_tag" = "$(git rev-parse "refs/tags/$tag")" ] || + fail "$tag on $GITEA_REMOTE is not the local $tag. Find out which one is right before publishing." + +notes=$(awk -v h="## $tag " ' + index($0, h) == 1 { found = 1; next } + found && /^## / { exit } + found { print } +' CHANGELOG.md | sed -e '/./,$!d') +[ -n "$notes" ] || fail "CHANGELOG.md has no text under '## $tag'" + +call GET "$api" +case $status in + 200) ;; + 401 | 403) fail "Gitea refused the token ($status). It needs write:repository on $GITEA_REPO." ;; + 404) fail "no repository $GITEA_REPO on $GITEA_URL, or the token cannot see it" ;; + *) fail "checking $GITEA_REPO returned HTTP $status: $(cat "$tmp/body")" ;; +esac +call GET "$api/releases/tags/$tag" +case $status in + 404) ;; + 200) fail "$tag is already published: $(jq -r .html_url "$tmp/body"). Delete that release on Gitea to publish it again." ;; + *) fail "checking for an existing release returned HTTP $status: $(cat "$tmp/body")" ;; +esac + +echo "Building the Flatpak bundle for $tag" +"${MAKE:-make}" --no-print-directory flatpak-bundle +cp target/flatpak/remus.flatpak "target/flatpak/$asset" + +body=$(jq -n --arg tag "$tag" --arg notes "$notes" \ + '{tag_name: $tag, name: $tag, body: $notes, draft: false, prerelease: false}') +call POST "$api/releases" -H 'Content-Type: application/json' --data "$body" +[ "$status" = 201 ] || fail "creating the release returned HTTP $status: $(cat "$tmp/body")" +id=$(jq -r .id "$tmp/body") +url=$(jq -r .html_url "$tmp/body") + +call POST "$api/releases/$id/assets?name=$asset" -F "attachment=@target/flatpak/$asset" +if [ "$status" != 201 ]; then + echo "error: uploading $asset returned HTTP $status: $(cat "$tmp/body")" >&2 + # A release without its bundle would block the next try, so take it back. + call DELETE "$api/releases/$id" + if [ "$status" = 204 ]; then + echo "Removed the release again, so make publish can be rerun." >&2 + else + echo "Could not remove the release ($status). Delete $url by hand before rerunning." >&2 + fi + exit 1 +fi + +echo "Published $tag with $asset: $url"