BlueGit

ict rusty-teams

Files

rusty-teams / packaging / kvt / release-assets.sh

release-assets.sh

release-assets.sh 2.6 KiB Download Raw
1#!/usr/bin/env bash
2# KVT fork: the release assets of a tag pipeline on git.kvt.nl.
3# release-assets.sh sums <tag> writes dist/kvt/SHA256SUMS
4# release-assets.sh json <tag> <commit> body for POST .../releases/<tag>/assets
5#
6# BlueGit artifacts have fixed paths, so the build jobs write fixed names under
7# dist/kvt and the release gives each file its versioned name. The updater and the
8# AUR package look for exactly these names:
9# rusty-teams-<v>-linux-amd64 bare binary, Linux self-update (linux_release)
10# rusty-teams-<v>-linux-x86_64.tar.gz FHS tree, source of kvt-rusty-teams-bin (linux_release)
11# rusty-teams-<v>-windows-amd64.exe Windows self-update (windows_release)
12# SHA256SUMS the updater checks these before it installs (checksums)
13# The Windows exe is left out when windows_release failed (it has allow_failure).
14set -euo pipefail
15DIST="${DIST:-dist/kvt}"
16
17# job|artifact path|asset suffix
18TABLE="linux_release|teams-linux-amd64|-linux-amd64
19linux_release|linux-x86_64.tar.gz|-linux-x86_64.tar.gz
20windows_release|teams-windows-amd64.exe|-windows-amd64.exe"
21
22present() {
23 local version="${1#v}" job file suffix
24 while IFS='|' read -r job file suffix; do
25 [[ -f "$DIST/$file" ]] && printf '%s|%s|%s\n' "$job" "$DIST/$file" "rusty-teams-$version$suffix"
26 done <<<"$TABLE"
27 return 0
28}
29
30case "${1:-}" in
31 sums)
32 tag="${2:?tag}"
33 for required in teams-linux-amd64 linux-x86_64.tar.gz; do
34 [[ -f "$DIST/$required" ]] || { echo "missing $DIST/$required (job linux_release)" >&2; exit 1; }
35 done
36 [[ -f "$DIST/teams-windows-amd64.exe" ]] ||
37 echo "WARNING: no Windows build in this release (windows_release failed); Windows installs are not offered it." >&2
38 : > "$DIST/SHA256SUMS.tmp"
39 while IFS='|' read -r _job path name; do
40 printf '%s %s\n' "$(sha256sum "$path" | awk '{print $1}')" "$name" >> "$DIST/SHA256SUMS.tmp"
41 done < <(present "$tag")
42 mv "$DIST/SHA256SUMS.tmp" "$DIST/SHA256SUMS"
43 cat "$DIST/SHA256SUMS"
44 ;;
45 json)
46 tag="${2:?tag}" commit="${3:?commit}"
47 [[ "$commit" =~ ^[0-9a-f]{40}$ ]] || { echo "commit must be a full sha" >&2; exit 1; }
48 printf '{"commit":"%s","name":"%s","body":"Rusty Teams (KVT) %s","assets":[' "$commit" "$tag" "$tag"
49 while IFS='|' read -r job path name; do
50 printf '{"job":"%s","path":"%s","name":"%s"},' "$job" "$path" "$name"
51 done < <(present "$tag")
52 printf '{"job":"checksums","path":"%s/SHA256SUMS","name":"SHA256SUMS"}]}\n' "$DIST"
53 ;;
54 *) echo "usage: $0 sums <tag> | json <tag> <commit>" >&2; exit 2 ;;
55esac