Skip to content

Commit fa4200b

Browse files
Accept goreleaser checksum format in release scripts
Co-authored-by: Andrew <andrewxhill@gmail.com>
1 parent 55fd5a5 commit fa4200b

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

scripts/generate-homebrew-formula.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fi
3838

3939
sha_for() {
4040
local name="$1"
41-
awk -v target="./${name}" '$2 == target { print $1 }' "${checksums}"
41+
awk -v bare="${name}" -v dotted="./${name}" '$2 == bare || $2 == dotted { print $1; exit }' "${checksums}"
4242
}
4343

4444
darwin_amd64_archive="mainline_${version}_darwin_amd64.tar.gz"

scripts/generate-release-manifest.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ json_escape() {
5858
python3 -c 'import json,sys; print(json.dumps(sys.argv[1]))' "$1"
5959
}
6060

61+
sha_for() {
62+
local name="$1"
63+
awk -v bare="${name}" -v dotted="./${name}" '$2 == bare || $2 == dotted { print $1; exit }' "${checksums}"
64+
}
65+
6166
{
6267
printf '{\n'
6368
printf ' "version": %s,\n' "$(json_escape "${version}")"
@@ -80,7 +85,7 @@ json_escape() {
8085
if [[ "${goos}" = "windows" ]]; then
8186
name="mainline_${version}_${goos}_${goarch}.zip"
8287
fi
83-
sha="$(awk -v target="./${name}" '$2 == target { print $1 }' "${checksums}")"
88+
sha="$(sha_for "${name}")"
8489
if [[ -z "${sha}" ]]; then
8590
echo "missing checksum for ${name}" >&2
8691
exit 1

scripts/test-build-release.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ test -f "${output_dir}/SHA256SUMS"
2727
tar -tzf "${output_dir}/mainline_v0.0.0-test_linux_amd64.tar.gz" | grep -q 'mainline_v0.0.0-test_linux_amd64/mainline$'
2828
unzip -Z1 "${output_dir}/mainline_v0.0.0-test_windows_amd64.zip" | grep -q '^mainline_v0.0.0-test_windows_amd64/mainline.exe$'
2929

30+
bare_checksums="${output_dir}/SHA256SUMS.bare"
31+
sed 's# \./# #g' "${output_dir}/SHA256SUMS" > "${bare_checksums}"
32+
"${repo_root}/scripts/generate-homebrew-formula.sh" --version v0.0.0-test --checksums "${bare_checksums}" --output "${output_dir}/mainline.rb"
33+
"${repo_root}/scripts/generate-release-manifest.sh" --version v0.0.0-test --checksums "${bare_checksums}" --output "${output_dir}/release-manifest.json"
34+
ruby -c "${output_dir}/mainline.rb" >/dev/null
35+
grep -q '"name": "mainline_v0.0.0-test_darwin_amd64.tar.gz"' "${output_dir}/release-manifest.json"
36+
3037
host_os="$(uname -s | tr '[:upper:]' '[:lower:]')"
3138
host_arch="$(uname -m)"
3239
case "${host_arch}" in

0 commit comments

Comments
 (0)