mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 21:36:40 -10:00
Prereleases now reach the Homebrew tap through a second formula, `devvm-rc`. The stable `devvm` formula stays on the last final release. Co-authored-by: Claude Opus 5.5 <[email protected]>
262 lines
11 KiB
Plaintext
262 lines
11 KiB
Plaintext
# scripts/release.sh --head: a test build from HEAD's commit, signed with a
|
|
# test key, in a throwaway repo with a goreleaser that writes a small dist/.
|
|
[!exec:git] skip
|
|
[!exec:minisign] skip
|
|
env GIT_CONFIG_NOSYSTEM=1
|
|
env PATH=$WORK/bin:$PATH
|
|
chmod 755 bin/goreleaser
|
|
exec bash repo.sh
|
|
|
|
# Unsigned without a test key: install.sh trusts no key.
|
|
exec repo/scripts/release.sh --head
|
|
stdout '^\(not signed: a test build without DEVVM_MINISIGN_KEY\)$'
|
|
! exists repo/dist/SHA256SUMS.minisig
|
|
grep '^release_version="1.2.3"$' repo/dist/install.sh
|
|
grep '^minisign_key=""$' repo/dist/install.sh
|
|
|
|
# With one: GoReleaser builds a snapshot with VERSION's version, SHA256SUMS
|
|
# is signed and verifies, install.sh is set to the release and the key, and
|
|
# the formula to each platform's archive.
|
|
rm log
|
|
exec minisign -G -W -p keys/test.pub -s keys/test.key
|
|
env DEVVM_MINISIGN_KEY=$WORK/keys/test.key DEVVM_MINISIGN_PUB=$WORK/keys/test.pub
|
|
exec repo/scripts/release.sh --head
|
|
! stdout 'not signed'
|
|
cmp log log.want
|
|
exec minisign -Vm repo/dist/SHA256SUMS -p keys/test.pub
|
|
stdout 'Trusted comment: devvm 1.2.3'
|
|
exec bash key.sh
|
|
grep '^release_version="1.2.3"$' repo/dist/install.sh
|
|
cmp stdout key.want
|
|
exec bash sums.sh
|
|
cmp stdout sums.want
|
|
exec bash formula.sh devvm.rb
|
|
cmp stdout formula.want
|
|
exec bash formula.sh devvm-rc.rb
|
|
cmp stdout formula.want
|
|
|
|
# A release gets both formulas, devvm and devvm-rc, each conflicting with
|
|
# the other: they differ only in that.
|
|
exec bash -c 'diff repo/dist/devvm.rb repo/dist/devvm-rc.rb || true'
|
|
cmp stdout formulas.diff
|
|
|
|
# --formula-from: the same formulas from a published release's signed
|
|
# SHA256SUMS, checked against packaging/minisign.pub and its trusted
|
|
# comment; a changed one refused, and one signed as another release's.
|
|
mkdir pub
|
|
cp repo/dist/SHA256SUMS repo/dist/SHA256SUMS.minisig pub/
|
|
cp repo/dist/devvm.rb devvm.rb.built
|
|
cp repo/dist/devvm-rc.rb devvm-rc.rb.built
|
|
cp keys/test.pub repo/packaging/minisign.pub
|
|
exec repo/scripts/release.sh --formula-from $WORK/pub
|
|
stdout '^==> dist/devvm\.rb for devvm 1\.2\.3, from '
|
|
stdout '^==> dist/devvm-rc\.rb for devvm 1\.2\.3, from '
|
|
cmp repo/dist/devvm.rb devvm.rb.built
|
|
cmp repo/dist/devvm-rc.rb devvm-rc.rb.built
|
|
exec bash -c 'echo 1.2.4 > repo/VERSION'
|
|
! exec repo/scripts/release.sh --formula-from $WORK/pub
|
|
stderr '^release: \S+/SHA256SUMS is signed as ''devvm 1\.2\.3'', not VERSION''s ''devvm 1\.2\.4''$'
|
|
exec git -C repo checkout -q VERSION
|
|
exec bash -c 'echo x >> pub/SHA256SUMS'
|
|
! exec repo/scripts/release.sh --formula-from $WORK/pub
|
|
stderr 'SHA256SUMS doesn''t verify with packaging/minisign.pub$'
|
|
|
|
# The formula substitution, whole: a prerelease's SHA256SUMS gives only
|
|
# devvm-rc.rb, its class, its conflict and each platform's URL and
|
|
# checksum in place.
|
|
mkdir pubrc
|
|
cp sums.rc pubrc/SHA256SUMS
|
|
exec minisign -Sm pubrc/SHA256SUMS -s keys/test.key -t 'devvm 1.3.0-rc.1' -x pubrc/SHA256SUMS.minisig
|
|
exec bash -c 'echo 1.3.0-rc.1 > repo/VERSION'
|
|
rm repo/dist/devvm.rb repo/dist/devvm-rc.rb
|
|
exec repo/scripts/release.sh --formula-from $WORK/pubrc
|
|
! stdout 'dist/devvm\.rb'
|
|
! exists repo/dist/devvm.rb
|
|
exec grep -v '^#' repo/dist/devvm-rc.rb
|
|
cmp stdout devvm-rc.want
|
|
exec git -C repo checkout -q VERSION
|
|
rm repo/packaging/minisign.pub
|
|
|
|
# Only what's committed goes in.
|
|
exec tar -tzf repo/dist/devvm-1.2.3.tar.gz
|
|
stdout '^devvm-1.2.3/VERSION$'
|
|
! stdout uncommitted
|
|
|
|
# A prerelease's VERSION, 1.3.0-rc.1: its archives, install.sh and the
|
|
# trusted comment all name it, it gets only the formula devvm-rc, and the
|
|
# formula devvm is said to keep the last release.
|
|
exec bash -c 'echo 1.3.0-rc.1 > repo/VERSION && git -C repo commit -qam rc'
|
|
exec repo/scripts/release.sh --head
|
|
stdout 'GitHub prerelease v1\.3\.0-rc\.1, devvm-rc\.rb to devvmhq/homebrew-tap''s Formula/; the formula devvm keeps the last release\.$'
|
|
exists repo/dist/devvm-1.3.0-rc.1-linux-arm64.tar.gz
|
|
exists repo/dist/devvm-1.3.0-rc.1.tar.gz
|
|
grep '^release_version="1.3.0-rc.1"$' repo/dist/install.sh
|
|
! exists repo/dist/devvm.rb
|
|
grep '^class DevvmRc < Formula$' repo/dist/devvm-rc.rb
|
|
grep '^ conflicts_with "devvmhq/tap/devvm", because: "both install the devvm binary"$' repo/dist/devvm-rc.rb
|
|
grep 'releases/download/v1\.3\.0-rc\.1/devvm-1\.3\.0-rc\.1-darwin-arm64\.tar\.gz"$' repo/dist/devvm-rc.rb
|
|
exec bash formula.sh devvm-rc.rb
|
|
stdout '^https://github.com/devvmhq/devvm/releases/download/v1\.3\.0-rc\.1/devvm-1\.3\.0-rc\.1-linux-amd64\.tar\.gz checksum$'
|
|
stdout '^comments$'
|
|
exec minisign -Vm repo/dist/SHA256SUMS -p keys/test.pub
|
|
stdout 'Trusted comment: devvm 1\.3\.0-rc\.1$'
|
|
exec bash -c 'echo 1.2.3 > repo/VERSION && git -C repo commit -qam back'
|
|
|
|
# A key that doesn't match the public key: refused.
|
|
exec minisign -G -W -p keys/other.pub -s keys/other.key
|
|
env DEVVM_MINISIGN_PUB=$WORK/keys/other.pub
|
|
! exec repo/scripts/release.sh --head
|
|
stderr '^release: SHA256SUMS.minisig doesn''t verify with packaging/minisign.pub$'
|
|
env DEVVM_MINISIGN_PUB=$WORK/keys/test.pub
|
|
|
|
# A binary that doesn't say the release's version: refused.
|
|
env GR_VERSION=0.0.0
|
|
! exec repo/scripts/release.sh --head
|
|
stderr 'version says ''0.0.0'', not 1.2.3$'
|
|
env GR_VERSION=
|
|
|
|
# An install.sh without the lines to fill in: refused.
|
|
exec bash -c 'printf ''#!/bin/sh\n'' > repo/install.sh && git -C repo commit -qam no-lines'
|
|
! exec repo/scripts/release.sh --head
|
|
stderr 'install.sh needs one release_version="" and one minisign_key="" line$'
|
|
|
|
# A VERSION that isn't x.y.z or x.y.z-rc.N: refused.
|
|
exec bash -c 'echo 1.2 > repo/VERSION && git -C repo commit -qam bad-version'
|
|
! exec repo/scripts/release.sh --head
|
|
stderr '^release: VERSION isn''t x.y.z or x.y.z-rc.N: ''1.2''$'
|
|
exec bash -c 'echo 1.2.3-RC1 > repo/VERSION && git -C repo commit -qam bad-prerelease'
|
|
! exec repo/scripts/release.sh --head
|
|
stderr '^release: VERSION isn''t x.y.z or x.y.z-rc.N: ''1.2.3-RC1''$'
|
|
|
|
# A HEAD without install.sh: refused too.
|
|
exec bash -c 'echo 1.2.3 > repo/VERSION && git -C repo rm -q install.sh && git -C repo commit -qam no-install'
|
|
! exec repo/scripts/release.sh --head
|
|
stderr '^release: no install.sh in HEAD$'
|
|
|
|
-- repo.sh --
|
|
# A repo with release.sh, the formula, an install.sh to fill in and
|
|
# VERSION 1.2.3, and a file that isn't committed.
|
|
set -eu
|
|
mkdir -p repo/scripts repo/packaging/homebrew keys
|
|
cp "$DEVVM_REPO/scripts/release.sh" repo/scripts/
|
|
cp "$DEVVM_REPO/packaging/homebrew/devvm.rb" repo/packaging/homebrew/
|
|
echo 1.2.3 > repo/VERSION
|
|
printf '#!/bin/sh\nrelease_version=""\nminisign_key=""\n' > repo/install.sh
|
|
git -C repo init -q
|
|
git -C repo config user.email e@e
|
|
git -C repo config user.name e
|
|
git -C repo add -A
|
|
git -C repo commit -qm r
|
|
touch repo/uncommitted
|
|
-- key.sh --
|
|
# install.sh's key is the test key's.
|
|
grep "^minisign_key=\"$(sed -n 2p keys/test.pub)\"$" repo/dist/install.sh >/dev/null && echo trusted
|
|
-- key.want --
|
|
trusted
|
|
-- sums.sh --
|
|
# The signed SHA256SUMS has install.sh's checksum, as it's written in
|
|
# dist/, so you can check the script before you run it.
|
|
cd repo/dist
|
|
{ sha256sum -c --ignore-missing SHA256SUMS 2>/dev/null || shasum -a 256 -c --ignore-missing SHA256SUMS; } | grep '^install.sh'
|
|
-- sums.want --
|
|
install.sh: OK
|
|
-- formula.sh --
|
|
# Formula $1's each platform's URL, and the checksum after it, against each
|
|
# archive's own and SHA256SUMS's line for it.
|
|
f=repo/dist/$1
|
|
grep -A1 '^ url ' "$f" | grep -v '^--$' | sed -n 'N;s/\n/ /;p' | while read -r _ u _ s; do
|
|
u=${u//\"/}; s=${s//\"/}; a=${u##*/}
|
|
sha=$({ sha256sum 2>/dev/null || shasum -a 256; } < "repo/dist/$a" | cut -c1-64)
|
|
[ "$s" = "$sha" ] && grep -q "^$sha $a$" repo/dist/SHA256SUMS && echo "$u checksum"
|
|
done
|
|
# Nothing left to fill in, and the comments as the template has them.
|
|
grep -v '^#' "$f" | grep '@' || true
|
|
diff <(grep '^#' repo/packaging/homebrew/devvm.rb) <(grep '^#' "$f") && echo comments
|
|
-- formula.want --
|
|
https://github.com/devvmhq/devvm/releases/download/v1.2.3/devvm-1.2.3-darwin-arm64.tar.gz checksum
|
|
https://github.com/devvmhq/devvm/releases/download/v1.2.3/devvm-1.2.3-darwin-amd64.tar.gz checksum
|
|
https://github.com/devvmhq/devvm/releases/download/v1.2.3/devvm-1.2.3-linux-arm64.tar.gz checksum
|
|
https://github.com/devvmhq/devvm/releases/download/v1.2.3/devvm-1.2.3-linux-amd64.tar.gz checksum
|
|
comments
|
|
-- formulas.diff --
|
|
6c6
|
|
< class Devvm < Formula
|
|
---
|
|
> class DevvmRc < Formula
|
|
35c35
|
|
< conflicts_with "devvmhq/tap/devvm-rc", because: "both install the devvm binary"
|
|
---
|
|
> conflicts_with "devvmhq/tap/devvm", because: "both install the devvm binary"
|
|
-- sums.rc --
|
|
1111111111111111111111111111111111111111111111111111111111111111 devvm-1.3.0-rc.1-darwin-arm64.tar.gz
|
|
2222222222222222222222222222222222222222222222222222222222222222 devvm-1.3.0-rc.1-darwin-amd64.tar.gz
|
|
3333333333333333333333333333333333333333333333333333333333333333 devvm-1.3.0-rc.1-linux-arm64.tar.gz
|
|
4444444444444444444444444444444444444444444444444444444444444444 devvm-1.3.0-rc.1-linux-amd64.tar.gz
|
|
-- devvm-rc.want --
|
|
class DevvmRc < Formula
|
|
desc "Isolated Lima VM per project folder, with shared read-only toolchains"
|
|
homepage "https://github.com/devvmhq/devvm"
|
|
license "MIT"
|
|
|
|
depends_on "lima"
|
|
|
|
on_macos do
|
|
on_arm do
|
|
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-darwin-arm64.tar.gz"
|
|
sha256 "1111111111111111111111111111111111111111111111111111111111111111"
|
|
end
|
|
on_intel do
|
|
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-darwin-amd64.tar.gz"
|
|
sha256 "2222222222222222222222222222222222222222222222222222222222222222"
|
|
end
|
|
end
|
|
|
|
on_linux do
|
|
on_arm do
|
|
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-linux-arm64.tar.gz"
|
|
sha256 "3333333333333333333333333333333333333333333333333333333333333333"
|
|
end
|
|
on_intel do
|
|
url "https://github.com/devvmhq/devvm/releases/download/v1.3.0-rc.1/devvm-1.3.0-rc.1-linux-amd64.tar.gz"
|
|
sha256 "4444444444444444444444444444444444444444444444444444444444444444"
|
|
end
|
|
end
|
|
|
|
conflicts_with "devvmhq/tap/devvm", because: "both install the devvm binary"
|
|
|
|
def install
|
|
bin.install "devvm"
|
|
end
|
|
|
|
test do
|
|
assert_equal version.to_s, shell_output("#{bin}/devvm --version").strip
|
|
end
|
|
end
|
|
-- log.want --
|
|
release --clean --skip=publish --snapshot DEVVM_VERSION=1.2.3 GORELEASER_CURRENT_TAG=
|
|
-- bin/goreleaser --
|
|
#!/bin/bash
|
|
# Logs its call and writes a dist/ like GoReleaser's: each system's and
|
|
# processor's build, a script printing $GR_VERSION, else $DEVVM_VERSION, the
|
|
# Linux archives, the source tarball and SHA256SUMS.
|
|
set -eu
|
|
echo "$* DEVVM_VERSION=$DEVVM_VERSION GORELEASER_CURRENT_TAG=${GORELEASER_CURRENT_TAG:-}" >> "$WORK/log"
|
|
rm -rf dist
|
|
for os in darwin linux; do
|
|
for a in arm64 amd64; do
|
|
mkdir -p "dist/devvm_${os}_$a"
|
|
printf '#!/bin/sh\necho %s\n' "${GR_VERSION:-$DEVVM_VERSION}" > "dist/devvm_${os}_$a/devvm"
|
|
chmod 755 "dist/devvm_${os}_$a/devvm"
|
|
done
|
|
done
|
|
for os in darwin linux; do
|
|
for a in arm64 amd64; do
|
|
mkdir -p "dist/x/devvm-$DEVVM_VERSION-$os-$a"
|
|
cp "dist/devvm_${os}_$a/devvm" "dist/x/devvm-$DEVVM_VERSION-$os-$a/devvm"
|
|
tar -czf "dist/devvm-$DEVVM_VERSION-$os-$a.tar.gz" -C dist/x "devvm-$DEVVM_VERSION-$os-$a"
|
|
done
|
|
done
|
|
rm -rf dist/x
|
|
git archive --prefix="devvm-$DEVVM_VERSION/" HEAD | gzip -n > "dist/devvm-$DEVVM_VERSION.tar.gz"
|
|
(cd dist && { sha256sum devvm-*.tar.gz 2>/dev/null || shasum -a 256 devvm-*.tar.gz; } > SHA256SUMS)
|