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
|
||||
Reference in New Issue
Block a user