#!/bin/bash # Publishes cn-built packages into the Gitea [omarchycn] Arch registry. # usage: publish-cn-packages.sh ... (maintainer/release step) set -euo pipefail GITEA=${GITEA:-https://git.zacharyzhang.com} OWNER=${OWNER:-ZacharyZhang-NY} : "${PKG_SYNC_TOKEN:?PKG_SYNC_TOKEN (Gitea package-write token) is required}" (($# > 0)) || { echo "usage: publish-cn-packages.sh ..." >&2; exit 1; } for pkg in "$@"; do [[ -f $pkg ]] || { echo "no such file: $pkg" >&2; exit 1; } # Token travels via curl config on stdin, never in the process argument list code=$(curl -sS --retry 2 -o /tmp/publish.out -w '%{http_code}' -X PUT -K - \ --upload-file "$pkg" "$GITEA/api/packages/$OWNER/arch/omarchycn" \ <<< "header = \"Authorization: token $PKG_SYNC_TOKEN\"") case "$code" in 201) echo "published: ${pkg##*/}" ;; 409) echo "already present: ${pkg##*/}" ;; *) echo "upload of ${pkg##*/} failed (HTTP $code): $(head -c 300 /tmp/publish.out)" >&2 exit 1 ;; esac done