Add release workflow and docs
This commit is contained in:
97
.gitea/workflows/release.yml
Normal file
97
.gitea/workflows/release.yml
Normal file
@@ -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
|
||||
@@ -31,6 +31,8 @@ cargo install --git <repo-url> --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
|
||||
|
||||
21
docs/RELEASING.md
Normal file
21
docs/RELEASING.md
Normal file
@@ -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-<tag>-x86_64-linux-gnu.tar.gz`
|
||||
- `mov-renamarr-<tag>-arm64-linux-gnu.tar.gz`
|
||||
Reference in New Issue
Block a user