BUILDER
This commit is contained in:
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
: "${NEXSPENCE_URL:?Set Gitea secret NEXSPENCE_URL}"
|
||||
: "${NEXSPENCE_TOKEN:?Set Gitea secret NEXSPENCE_TOKEN}"
|
||||
: "${NEXSPENCE_REPOSITORY:=noko-arch}"
|
||||
|
||||
pkg="$(cat .package-path)"
|
||||
[[ -f "$pkg" ]] || { echo "Package not found: $pkg" >&2; exit 1; }
|
||||
|
||||
repo_name="$NEXSPENCE_REPOSITORY"
|
||||
base="${NEXSPENCE_URL%/}/repository/${repo_name}/x86_64"
|
||||
tmp="$(mktemp -d)"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
cp "$pkg" "$tmp/"
|
||||
pkg_file="$(basename "$pkg")"
|
||||
|
||||
# Raw hosted storage does not preserve repo-add symlinks, so upload both
|
||||
# compressed and uncompressed database files as real objects.
|
||||
repo-add --remove "$tmp/${repo_name}.db.tar.zst" "$tmp/$pkg_file"
|
||||
repo-add --remove "$tmp/${repo_name}.files.tar.zst" "$tmp/$pkg_file"
|
||||
zstd -q -d -c "$tmp/${repo_name}.db.tar.zst" > "$tmp/${repo_name}.db"
|
||||
zstd -q -d -c "$tmp/${repo_name}.files.tar.zst" > "$tmp/${repo_name}.files"
|
||||
|
||||
upload() {
|
||||
local file="$1"
|
||||
local remote="$base/$(basename "$file")"
|
||||
echo "==> PUT $(basename "$file")"
|
||||
curl --fail-with-body --retry 5 --retry-all-errors \
|
||||
--connect-timeout 20 --max-time 900 \
|
||||
-X PUT -H "Authorization: Bearer ${NEXSPENCE_TOKEN}" \
|
||||
--upload-file "$file" "$remote"
|
||||
}
|
||||
|
||||
upload "$tmp/$pkg_file"
|
||||
upload "$tmp/${repo_name}.db"
|
||||
upload "$tmp/${repo_name}.db.tar.zst"
|
||||
upload "$tmp/${repo_name}.files"
|
||||
upload "$tmp/${repo_name}.files.tar.zst"
|
||||
|
||||
echo "Published package and repository database to $base/"
|
||||
Reference in New Issue
Block a user