#!/usr/bin/env bash # KVT fork: the release assets of a tag pipeline on git.kvt.nl. # release-assets.sh sums writes dist/kvt/SHA256SUMS # release-assets.sh json body for POST .../releases//assets # # BlueGit artifacts have fixed paths, so the build jobs write fixed names under # dist/kvt and the release gives each file its versioned name. The updater and the # AUR package look for exactly these names: # rusty-teams--linux-amd64 bare binary, Linux self-update (linux_release) # rusty-teams--linux-x86_64.tar.gz FHS tree, source of kvt-rusty-teams-bin (linux_release) # rusty-teams--windows-amd64.exe Windows self-update (windows_release) # SHA256SUMS the updater checks these before it installs (checksums) # The Windows exe is left out when windows_release failed (it has allow_failure). set -euo pipefail DIST="${DIST:-dist/kvt}" # job|artifact path|asset suffix TABLE="linux_release|teams-linux-amd64|-linux-amd64 linux_release|linux-x86_64.tar.gz|-linux-x86_64.tar.gz windows_release|teams-windows-amd64.exe|-windows-amd64.exe" present() { local version="${1#v}" job file suffix while IFS='|' read -r job file suffix; do [[ -f "$DIST/$file" ]] && printf '%s|%s|%s\n' "$job" "$DIST/$file" "rusty-teams-$version$suffix" done <<<"$TABLE" return 0 } case "${1:-}" in sums) tag="${2:?tag}" for required in teams-linux-amd64 linux-x86_64.tar.gz; do [[ -f "$DIST/$required" ]] || { echo "missing $DIST/$required (job linux_release)" >&2; exit 1; } done [[ -f "$DIST/teams-windows-amd64.exe" ]] || echo "WARNING: no Windows build in this release (windows_release failed); Windows installs are not offered it." >&2 : > "$DIST/SHA256SUMS.tmp" while IFS='|' read -r _job path name; do printf '%s %s\n' "$(sha256sum "$path" | awk '{print $1}')" "$name" >> "$DIST/SHA256SUMS.tmp" done < <(present "$tag") mv "$DIST/SHA256SUMS.tmp" "$DIST/SHA256SUMS" cat "$DIST/SHA256SUMS" ;; json) tag="${2:?tag}" commit="${3:?commit}" [[ "$commit" =~ ^[0-9a-f]{40}$ ]] || { echo "commit must be a full sha" >&2; exit 1; } printf '{"commit":"%s","name":"%s","body":"Rusty Teams (KVT) %s","assets":[' "$commit" "$tag" "$tag" while IFS='|' read -r job path name; do printf '{"job":"%s","path":"%s","name":"%s"},' "$job" "$path" "$name" done < <(present "$tag") printf '{"job":"checksums","path":"%s/SHA256SUMS","name":"SHA256SUMS"}]}\n' "$DIST" ;; *) echo "usage: $0 sums | json " >&2; exit 2 ;; esac