musllvm

musl and LLVM cross-toolchain build system
git clone https://git.daat.foo/repos/musllvm.git
Log | Files | Refs | README | LICENSE

publish.sh (1999B)


      1 #!/bin/sh
      2 set -eu
      3 
      4 root=$(CDPATH= cd "$(dirname "$0")/.." && pwd -P)
      5 : "${GITHUB_SHA:?GITHUB_SHA must identify the build commit}"
      6 [ "$(git -C "$root" rev-parse HEAD)" = "$GITHUB_SHA" ] || {
      7 	printf '%s\n' 'checkout does not match the build commit' >&2
      8 	exit 1
      9 }
     10 date=$(git -C "$root" show -s --format=%cs "$GITHUB_SHA")
     11 short=$(printf '%.12s' "$GITHUB_SHA")
     12 tag="musllvm-$date-$short"
     13 
     14 cd "${1:-$root/build/releases}"
     15 set -- musllvm-x86_64-linux-musl-host-x86_64-linux.tar.xz \
     16 	musllvm-aarch64-linux-musl-host-x86_64-linux.tar.xz
     17 : > SHA256SUMS
     18 for archive do
     19 	[ -s "$archive" ] && [ -s "$archive.sha256" ] || {
     20 		printf 'missing release archive or checksum: %s\n' "$archive" >&2
     21 		exit 1
     22 	}
     23 	read -r digest filename extra < "$archive.sha256"
     24 	[ "$filename" = "$archive" ] && [ -z "$extra" ] || {
     25 		printf 'checksum does not name its release archive: %s\n' "$archive" >&2
     26 		exit 1
     27 	}
     28 	cat "$archive.sha256" >> SHA256SUMS
     29 done
     30 sha256sum -c SHA256SUMS
     31 cp "$root/sources.list" sources.list
     32 {
     33 	printf 'CI built these musllvm toolchains from commit %s.\n\n' "$GITHUB_SHA"
     34 	printf '%s\n' 'The tools run on x86_64 Linux with glibc 2.39 or newer.' \
     35 		'They target x86_64-linux-musl and aarch64-linux-musl.' \
     36 		'The archives include Clang, LLD and LLVM utilities.' '' 'core sources' '------------' ''
     37 	awk 'NF && $1 !~ /^#/ { printf "    %s  %s\n", $1, $2 }' sources.list
     38 	printf '\n%s\n' 'Verify downloads with sha256sum --ignore-missing -c SHA256SUMS.'
     39 } > notes.md
     40 
     41 if draft=$(gh release view "$tag" --json isDraft --jq .isDraft 2> view.err); then
     42 	if [ "$draft" = false ]; then
     43 		printf 'release already published: %s\n' "$tag"
     44 		exit
     45 	fi
     46 	gh release upload "$tag" "$@" SHA256SUMS sources.list --clobber
     47 elif grep -F 'release not found' view.err >/dev/null; then
     48 	gh release create "$tag" "$@" SHA256SUMS sources.list --draft \
     49 		--target "$GITHUB_SHA" --title "musllvm $date" --notes-file notes.md
     50 else
     51 	cat view.err >&2
     52 	exit 1
     53 fi
     54 gh release edit "$tag" --notes-file notes.md --draft=false --latest