Files
hex/.github/release/publish-github-release.sh
Dax 6958927696 Windows: hex.com console entry point beside the GUI hex.exe (#1374)
* Windows: ship hex.com, a console entry point beside the GUI hex.exe, on PATH

* lock, fmt, legacy adoption

* clippy

* build hex-console in its own cargo run: -p hex is ambiguous with the hex crate

* hex.com returns once the app starts; Ctrl+C only; install script and Setup replace a running hex.com; hex-console checks in Compile

* fmt

* installer test: exit 0 once every check passed
2026-11-05 06:52:51 -05:00

73 lines
2.5 KiB
Bash
Executable File

#!/bin/sh
# Mirrors a stable release's downloads to its GitHub release, byte for byte,
# and makes it GitHub's "Latest" release (the TypeScript SDK's releases never
# take it). Release runs it last, for stable only, after tag-release.sh tagged
# v<version> at the release commit; it never creates the tag itself. Nothing
# downloads through GitHub's releases/latest redirect: the badge is only a
# label.
#
# publish-github-release.sh <dist>
#
# Environment: HEX_VERSION, HEX_RELEASE_COMMIT, HEX_RELEASE_TAG,
# HEX_RELEASE_SOURCE (a checkout of the commit with docs/releases/), GH_TOKEN.
set -eu
repo=${HEX_RELEASE_REPO:-anomalyco/hex}
[ $# -eq 1 ] || {
echo "Usage: $0 <dist>" >&2
exit 1
}
dist=$1
version=${HEX_VERSION:?Set HEX_VERSION}
commit=${HEX_RELEASE_COMMIT:?Set HEX_RELEASE_COMMIT}
tag=${HEX_RELEASE_TAG:?Set HEX_RELEASE_TAG}
source=${HEX_RELEASE_SOURCE:?Set HEX_RELEASE_SOURCE}
# Only a stable X.Y.Z release is ever Latest; dev builds and prereleases never
# reach this script.
printf '%s\n' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' || {
echo "Only a stable X.Y.Z release goes to GitHub, not $version." >&2
exit 1
}
[ "$tag" = "v$version" ] || {
echo "The release tag is $tag, not v$version." >&2
exit 1
}
temporary=$(mktemp -d)
trap 'rm -rf "$temporary"' EXIT HUP INT TERM
assets=$(cd "$dist" && { ls hex-*.zip hex-*.dmg hex-*.exe hex-*.com hex-*-linux-* 2>/dev/null || true; })
[ -n "$assets" ] || {
echo "No release files in $dist." >&2
exit 1
}
notes="$source/docs/releases/$version.md"
test -f "$notes" || {
echo "Add release notes at docs/releases/$version.md." >&2
exit 1
}
tagged=$(gh api "repos/$repo/git/ref/tags/$tag" --jq .object.sha)
if [ "$tagged" != "$commit" ]; then
echo "Tag $tag names $tagged, not $commit." >&2
exit 1
fi
if ! gh release view "$tag" -R "$repo" --json name >/dev/null 2>&1; then
gh release create "$tag" -R "$repo" --verify-tag --title "Hex $version" \
--notes-file "$notes" --latest=true
fi
gh release view "$tag" -R "$repo" --json assets > "$temporary/release.json"
mkdir -p "$temporary/mirror"
for name in $assets; do
if ! jq -e --arg name "$name" '.assets | any(.name == $name)' "$temporary/release.json" >/dev/null; then
gh release upload "$tag" "$dist/$name" -R "$repo"
fi
gh release download "$tag" -R "$repo" --pattern "$name" --dir "$temporary/mirror" --clobber
cmp -s "$dist/$name" "$temporary/mirror/$name" || {
echo "GitHub's $name differs from the release bytes." >&2
exit 1
}
rm -f "$temporary/mirror/$name"
done
echo "https://github.com/$repo/releases/tag/$tag"