Version 1.0.0, release build script
- version.go/version.txt, --version flag, version in the help title - build.sh builds static binaries for macOS and Linux into ./bin - make build/install inject version.txt, make dist runs build.sh - README: binary downloads; development docs: release process Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
156bb18c91
commit
e5750ef24b
9 files changed
+162
-9
No files matched your search
@@ -0,0 +1,74 @@
|
||||
#!/bin/sh
|
||||
# Build ghosttyconf for the usual platforms into ./bin, auto-incrementing the
|
||||
# patch version by 0.0.1 on every build.
|
||||
#
|
||||
# version.txt holds the currently built version. Each run increments the patch
|
||||
# component, then builds every platform with that one version injected via
|
||||
# -ldflags, and writes it back. So version.txt always reflects the version of
|
||||
# the binaries just built, and all of them carry the same one. The literal in
|
||||
# version.go is only ever what a bare `go build` picks up.
|
||||
#
|
||||
# ./bin ends up with ghosttyconf-<goos>-<goarch>, one file per platform, which
|
||||
# `mgsh release <version>` attaches to the release as they are.
|
||||
#
|
||||
# Override the platform list to build just one:
|
||||
# PLATFORMS="linux/amd64" ./build.sh
|
||||
#
|
||||
# Set the version instead of bumping it:
|
||||
# VERSION=1.1.0 ./build.sh
|
||||
# The automatic bump only ever touches the last number, so a minor or major
|
||||
# step is a decision, and this is how it is made.
|
||||
#
|
||||
# Windows is not in the list: Ghostty does not run there.
|
||||
#
|
||||
# -s -w drops the symbol table and DWARF info, -trimpath keeps build paths out
|
||||
# of the binary; together they roughly halve it. Neither affects a panic trace.
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
PLATFORMS=${PLATFORMS:-"darwin/arm64 darwin/amd64 linux/amd64 linux/arm64"}
|
||||
|
||||
if [ -n "$VERSION" ]; then
|
||||
# Checked rather than trusted: this number goes into the binary, into
|
||||
# version.txt and onto the release tag.
|
||||
if ! printf '%s' "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
||||
echo "VERSION=$VERSION is not MAJOR.MINOR.PATCH" >&2
|
||||
exit 1
|
||||
fi
|
||||
NV="$VERSION"
|
||||
else
|
||||
V=$(cat version.txt 2>/dev/null || echo 1.0.0)
|
||||
|
||||
# split MAJOR.MINOR.PATCH and increment PATCH (no carry: 1.0.9 -> 1.0.10)
|
||||
MAJOR=${V%%.*}
|
||||
REST=${V#*.}
|
||||
MINOR=${REST%%.*}
|
||||
PATCH=${REST#*.}
|
||||
PATCH=$((PATCH + 1))
|
||||
NV="$MAJOR.$MINOR.$PATCH"
|
||||
fi
|
||||
|
||||
mkdir -p bin
|
||||
HOST="$(go env GOOS)/$(go env GOARCH)"
|
||||
|
||||
for p in $PLATFORMS; do
|
||||
os=${p%/*}
|
||||
arch=${p#*/}
|
||||
out="bin/ghosttyconf-$os-$arch"
|
||||
|
||||
# CGO_ENABLED=0 throughout: it makes the cross builds work without a
|
||||
# toolchain per target and the binaries static. ghosttyconf only runs
|
||||
# ghostty and osascript and reads files, so nothing is lost by dropping cgo.
|
||||
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" \
|
||||
go build -trimpath -ldflags "-s -w -X main.Version=$NV" -o "$out" .
|
||||
|
||||
if [ "$p" = "$HOST" ]; then
|
||||
ln -sf "ghosttyconf-$os-$arch" bin/ghosttyconf # the one for this machine
|
||||
echo " $out -> bin/ghosttyconf"
|
||||
else
|
||||
echo " $out"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$NV" > version.txt
|
||||
echo "built ghosttyconf v$NV"
|
||||
Reference in new issue
Block a user