From 7f685c42162e85d4bd9936a7b9d38a6232769f4b Mon Sep 17 00:00:00 2001 From: 44r0n7 <44r0n7+gitea@pm.me> Date: Tue, 30 Dec 2025 11:47:41 -0500 Subject: [PATCH] Add release workflow and docs --- .gitea/workflows/release.yml | 97 ++++++++++++++++++++++++++++++++++++ README.md | 2 + docs/RELEASING.md | 21 ++++++++ 3 files changed, 120 insertions(+) create mode 100644 .gitea/workflows/release.yml create mode 100644 docs/RELEASING.md diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..c238505 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,97 @@ +name: Release binaries + +on: + push: + tags: + - "v*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable + with: + targets: aarch64-unknown-linux-gnu + + - name: Install cross compiler + run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu + + - name: Build x86_64 + run: cargo build --release + + - name: Build arm64 + env: + CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc + AR_aarch64_unknown_linux_gnu: aarch64-linux-gnu-ar + run: cargo build --release --target aarch64-unknown-linux-gnu + + - name: Package artifacts + run: | + set -euo pipefail + TAG="${GITHUB_REF_NAME:-${GITEA_REF_NAME:-unknown}}" + mkdir -p dist/pkg-x86_64 dist/pkg-arm64 + + cp target/release/mov-renamarr dist/pkg-x86_64/ + cp README.md LICENSE CHANGELOG.md dist/pkg-x86_64/ + tar -C dist/pkg-x86_64 -czf "dist/mov-renamarr-${TAG}-x86_64-linux-gnu.tar.gz" . + + cp target/aarch64-unknown-linux-gnu/release/mov-renamarr dist/pkg-arm64/ + cp README.md LICENSE CHANGELOG.md dist/pkg-arm64/ + tar -C dist/pkg-arm64 -czf "dist/mov-renamarr-${TAG}-arm64-linux-gnu.tar.gz" . + + - name: Upload release assets + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + run: | + set -euo pipefail + if [ -z "${GITEA_TOKEN:-}" ]; then + echo "GITEA_TOKEN secret is required to upload release assets." + exit 1 + fi + TAG="${GITHUB_REF_NAME:-${GITEA_REF_NAME:-unknown}}" + API_URL="${GITHUB_API_URL:-${GITEA_API_URL:-}}" + if [ -z "$API_URL" ]; then + API_URL="${GITHUB_SERVER_URL}/api/v1" + fi + REPO="${GITHUB_REPOSITORY}" + + release_json=$(curl -sS -H "Authorization: token ${GITEA_TOKEN}" \ + "${API_URL}/repos/${REPO}/releases/tags/${TAG}") + release_id=$(python3 - <<'PY' +import json, sys +data = json.load(sys.stdin) +print(data.get("id", "")) +PY + <<<"$release_json") + + if [ -z "$release_id" ]; then + create_payload=$(python3 - <<'PY' +import json, os +print(json.dumps({ + "tag_name": os.environ["TAG"], + "name": os.environ["TAG"], + "body": "" +})) +PY + ) + release_json=$(curl -sS -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "$create_payload" \ + "${API_URL}/repos/${REPO}/releases") + release_id=$(python3 - <<'PY' +import json, sys +data = json.load(sys.stdin) +print(data.get("id", "")) +PY + <<<"$release_json") + fi + + for file in dist/*.tar.gz; do + name=$(basename "$file") + curl -sS -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @"$file" \ + "${API_URL}/repos/${REPO}/releases/${release_id}/assets?name=${name}" + done diff --git a/README.md b/README.md index 9e0b321..f66743e 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,8 @@ cargo install --git --locked cargo install --path . --locked ``` +Download a prebuilt binary from the Releases page. + ## Quick start :rocket: Create a default config (with comments) and see the config path: ```bash diff --git a/docs/RELEASING.md b/docs/RELEASING.md new file mode 100644 index 0000000..d872b18 --- /dev/null +++ b/docs/RELEASING.md @@ -0,0 +1,21 @@ +# Releasing + +This repo includes a Gitea Actions workflow that builds Linux binaries for +`x86_64` and `arm64` and uploads them to the release. + +## One-time setup (Gitea Actions) +1) Create a personal access token with repo write access. +2) Add it to the repo secrets as `GITEA_TOKEN`. + +## Release steps +1) Update `CHANGELOG.md`. +2) Create and push a tag: + ```bash + git tag -a vX.Y.Z -m "vX.Y.Z" + git push origin vX.Y.Z + ``` +3) The workflow builds and uploads binaries to the release. + +## Artifacts +- `mov-renamarr--x86_64-linux-gnu.tar.gz` +- `mov-renamarr--arm64-linux-gnu.tar.gz`