BlueGit

ict rusty-teams

Files

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

release-assets.sh

release-assets.sh 2.7 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# rusty-teams-<v>-windows-arm64.exe Windows on ARM self-update (windows_arm64_release)
13# SHA256SUMS the updater checks these before it installs (checksums)
14# Every release carries all four build assets (Tim, t2380u): `sums` refuses to run without one.
15set -euo pipefail
16DIST="${DIST:-dist/kvt}"
17
18# job|artifact path|asset suffix
19TABLE="linux_release|teams-linux-amd64|-linux-amd64
20linux_release|linux-x86_64.tar.gz|-linux-x86_64.tar.gz
21windows_release|teams-windows-amd64.exe|-windows-amd64.exe
22windows_arm64_release|teams-windows-arm64.exe|-windows-arm64.exe"
23
24present() {
25 local version="${1#v}" job file suffix
26 while IFS='|' read -r job file suffix; do
27 [[ -f "$DIST/$file" ]] && printf '%s|%s|%s\n' "$job" "$DIST/$file" "rusty-teams-$version$suffix"
28 done <<<"$TABLE"
29 return 0
30}
31
32case "${1:-}" in
33 sums)
34 tag="${2:?tag}"
35 for required in teams-linux-amd64:linux_release linux-x86_64.tar.gz:linux_release \
36 teams-windows-amd64.exe:windows_release teams-windows-arm64.exe:windows_arm64_release; do
37 [[ -f "$DIST/${required%%:*}" ]] || { echo "missing $DIST/${required%%:*} (job ${required##*:})" >&2; exit 1; }
38 done
39 : > "$DIST/SHA256SUMS.tmp"
40 while IFS='|' read -r _job path name; do
41 printf '%s %s\n' "$(sha256sum "$path" | awk '{print $1}')" "$name" >> "$DIST/SHA256SUMS.tmp"
42 done < <(present "$tag")
43 mv "$DIST/SHA256SUMS.tmp" "$DIST/SHA256SUMS"
44 cat "$DIST/SHA256SUMS"
45 ;;
46 json)
47 tag="${2:?tag}" commit="${3:?commit}"
48 [[ "$commit" =~ ^[0-9a-f]{40}$ ]] || { echo "commit must be a full sha" >&2; exit 1; }
49 printf '{"commit":"%s","name":"%s","body":"Rusty Teams (KVT) %s","assets":[' "$commit" "$tag" "$tag"
50 while IFS='|' read -r job path name; do
51 printf '{"job":"%s","path":"%s","name":"%s"},' "$job" "$path" "$name"
52 done < <(present "$tag")
53 printf '{"job":"checksums","path":"%s/SHA256SUMS","name":"SHA256SUMS"}]}\n' "$DIST"
54 ;;
55 *) echo "usage: $0 sums <tag> | json <tag> <commit>" >&2; exit 2 ;;
56esac