Some checks failed
release / build-release (push) Failing after 4m23s
Rust CLI for Nginx Proxy Manager via its API, with sudo-like token auth (login prompts for password, caches only a short-lived token, never the password) and a generic `api` command to talk to any HTTP API. Commands: login/logout/status, list-hosts/get-host/find, add-proxy, enable/disable/delete-host, list-certs/add-cert/renew-cert, dump (JSON backup), apply (declarative), and generic api (method/url/header/data/ auth-key/insecure). Includes clap help + help-on-bad-input, Gitea Actions release workflow (arm64 native + x64 cross), VS Code build task (-> ./build), README and MIT license. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011YPrEZVBpPVoCRyJz2exkZ
88 lines
3.8 KiB
YAML
88 lines
3.8 KiB
YAML
name: release
|
|
|
|
# Bygger fristående npmctl-binärer för linux-arm64 (native på Pi-runnern) och
|
|
# linux-x64 (cross via gcc-x86-64-linux-gnu) och publicerar dem som assets på
|
|
# en Gitea-release. Runnern använder sin egen GITHUB_TOKEN mot Gitea-API:t —
|
|
# ingen token behöver hanteras manuellt.
|
|
on:
|
|
push:
|
|
branches: [main, master] # varje main-push -> rullande 'latest'-release
|
|
tags: ["v*"] # vX.Y.Z -> versionerad release
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: "Release-tag (lämna tom för 'latest')"
|
|
required: false
|
|
|
|
jobs:
|
|
build-release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Bestäm tag
|
|
id: t
|
|
run: |
|
|
case "$GITHUB_REF" in
|
|
refs/tags/*) T="$GITHUB_REF_NAME" ;;
|
|
*) T="${{ inputs.tag }}"; [ -z "$T" ] && T="latest" ;;
|
|
esac
|
|
echo "tag=$T" >> "$GITHUB_OUTPUT"
|
|
echo "bygger release: $T"
|
|
|
|
- name: Installera toolchain + bygg binärer
|
|
run: |
|
|
set -eux
|
|
SUDO=""; [ "$(id -u)" -ne 0 ] && SUDO=sudo
|
|
$SUDO apt-get update
|
|
$SUDO apt-get install -y --no-install-recommends gcc gcc-x86-64-linux-gnu jq curl ca-certificates
|
|
|
|
# Rust (om det saknas på runnern).
|
|
if ! command -v cargo >/dev/null 2>&1; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
|
|
fi
|
|
. "$HOME/.cargo/env"
|
|
|
|
rustup target add aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu
|
|
|
|
mkdir -p dist
|
|
|
|
# arm64 — native på Pi-runnern.
|
|
cargo build --release --target aarch64-unknown-linux-gnu
|
|
cp target/aarch64-unknown-linux-gnu/release/npmctl dist/npmctl-linux-arm64
|
|
|
|
# x64 — cross. Peka ut cross-linker och C-compiler (för ring).
|
|
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc
|
|
export CC_x86_64_unknown_linux_gnu=x86_64-linux-gnu-gcc
|
|
export AR_x86_64_unknown_linux_gnu=x86_64-linux-gnu-ar
|
|
cargo build --release --target x86_64-unknown-linux-gnu
|
|
cp target/x86_64-unknown-linux-gnu/release/npmctl dist/npmctl-linux-x64
|
|
|
|
cd dist
|
|
sha256sum npmctl-linux-* > checksums.txt
|
|
ls -la
|
|
|
|
- name: Skapa Gitea-release + ladda upp assets
|
|
env:
|
|
API: http://gitea-d:3000/api/v1
|
|
REPO: ${{ github.repository }}
|
|
TAG: ${{ steps.t.outputs.tag }}
|
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
set -eu
|
|
B=dist
|
|
BODY="npmctl $TAG — CLI för Nginx Proxy Manager (linux x64/arm64). Se wiki: https://gitea.brasse-pc.eu/brasse/Npm-cli/wiki"
|
|
rid=$(curl -s -X POST "$API/repos/$REPO/releases" -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"$BODY\"}" | jq -r '.id // empty')
|
|
[ -z "$rid" ] && rid=$(curl -s "$API/repos/$REPO/releases/tags/$TAG" -H "Authorization: token $TOKEN" | jq -r '.id')
|
|
echo "release id: $rid"
|
|
for f in npmctl-linux-x64 npmctl-linux-arm64 checksums.txt; do
|
|
aid=$(curl -s "$API/repos/$REPO/releases/$rid/assets" -H "Authorization: token $TOKEN" | jq -r ".[] | select(.name==\"$f\") | .id")
|
|
if [ -n "$aid" ] && [ "$aid" != "null" ]; then
|
|
echo "ersätter befintlig $f (id $aid)"
|
|
curl -s -X DELETE "$API/repos/$REPO/releases/$rid/assets/$aid" -H "Authorization: token $TOKEN" -o /dev/null
|
|
fi
|
|
echo "laddar upp $f ..."
|
|
curl -s -X POST "$API/repos/$REPO/releases/$rid/assets?name=$f" -H "Authorization: token $TOKEN" -F "attachment=@$B/$f" -o /dev/null -w " -> HTTP %{http_code}\n"
|
|
done
|