mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
scripts/publish.sh's default is now the maintainer's whole part of a release that CI builds and the co-signer publishes: the tag's checks, then main and the tag pushed to origin, which starts the Release workflow, and what comes next. It needs git alone. It refuses a tag whose commit has no release keys, which CI's workflow would refuse, and a version with no changelog entry, which the co-signer takes the notes from. - scripts/publish.sh --sign-legacy, the one command for the bridge: VERSION's draft release, which the co-signer made, has SHA256SUMS, SHA256SUMS.ci.minisig and SHA256SUMS.cosign.minisig downloaded, and scripts/release.sh --sign-legacy checks both signatures with this checkout's packaging/keys and devvm-release <version>, then signs SHA256SUMS with the old key, devvm <version>, and checks that with packaging/minisign.pub; after asking once, SHA256SUMS.minisig goes on the draft, which the co-signer waits for, then publishes. A draft that has it already, or a published release, or a draft without the co-signer's signature yet, is said so, and nothing is uploaded. A checkout without the release keys is refused before anything is signed, pointing at github-setup.md's step 1, as is the default mode's tag without them. - scripts/publish.sh --local, the old path, as it was: built, signed with the old key alone and published from this machine. It stays until the GitHub setup for CI and the co-signer is done, and goes when the bridge ends, as a release that only the old key signed is then one no devvm accepts. A flag, not the default, because the default is what's documented and what's safe to run at any time: it publishes nothing itself, so run before the setup it only pushes a tag whose workflow run fails; and a --local release after the co-signer starts is one it alerts on, as it didn't publish it. - scripts/release.sh --check-tag: --check's tag and keys checks alone, with no container runtime or signing key, which the default mode runs. - The shared parts are one function each: check_tag (the tag, main and origin), notes (the changelog entry), ask (the question), needs_gh. - release.sh's closing line names publish.sh --local, and --tag's build, CI's and the co-signer's, has none. Tests: testdata/script/publish_tag.txtar (the modes in --help, two modes refused, no tag, another signer, a dirty tree, no release keys, no changelog entry, a tag off main's HEAD, --dry-run, n, y and the pushes in order, again with nothing to push, origin's other tag; --sign-legacy: gh logged out, no draft, no co-signer signature yet, a co-signer signature by another key, CI's for another version, --dry-run, y and the upload, which verifies as devvm 1.2.3, again with nothing to do, a published release, a checkout without the release keys), failing before the code; publish.txtar runs the old path as --local, in a repo without release keys, as devvm is until they're made: SHA256SUMS signed with the old key alone, no role signatures, install.sh's key lines empty. Co-Authored-By: Claude Opus 5.5 <[email protected]>
548 lines
23 KiB
Plaintext
548 lines
23 KiB
Plaintext
# scripts/publish.sh --local, a release built, signed and published from
|
|
# this machine: the checks, --dry-run, the question, and each step,
|
|
# against a throwaway repo whose origin is a local bare repo, a local bare
|
|
# tap, a gh that keeps its release in $WORK/gh, SSH-signed tags, a
|
|
# minisign key without a password and a goreleaser that writes a small
|
|
# dist/. Pushes and gh's calls go in $WORK/calls, in order.
|
|
# publish_tag.txtar has the release CI builds and the co-signer publishes.
|
|
# The system's commands, not the stubs (ssh-keygen's): git signs with
|
|
# ssh-keygen. minisign is linked in from PATH first.
|
|
[!exec:git] skip
|
|
[!exec:minisign] skip
|
|
exec bash -c 'ln -s "$(command -v minisign)" bin/minisign'
|
|
env GIT_CONFIG_NOSYSTEM=1
|
|
env PATH=$WORK/bin:/usr/bin:/bin
|
|
env DEVVM_RELEASE_TEST_FILE_URLS=$WORK/tools
|
|
chmod 755 bin/goreleaser
|
|
chmod 755 bin/podman
|
|
chmod 755 bin/gh
|
|
exec bash repo.sh
|
|
env DEVVM_TAP_DIR=$WORK/tap
|
|
env DEVVM_MINISIGN_KEY=$WORK/keys/release.key
|
|
|
|
# --help: the script's header.
|
|
exec repo/scripts/publish.sh --local --help
|
|
stdout '^ scripts/publish.sh --local '
|
|
! exec repo/scripts/publish.sh --local --publish
|
|
stderr '^publish: unknown argument ''--publish''$'
|
|
|
|
# No tag yet: refused, by release.sh's check.
|
|
! exec repo/scripts/publish.sh --local --dry-run
|
|
stderr '^release: no tag v1.2.3: tag the release first'
|
|
|
|
# A tag by a key git trusts but packaging/release-signer doesn't pin:
|
|
# refused.
|
|
exec bash tag.sh other
|
|
! exec repo/scripts/publish.sh --local --dry-run
|
|
stderr '^release: tag v1.2.3 is signed by SHA256:\S+, not a key in packaging/release-signer$'
|
|
exec bash tag.sh good
|
|
|
|
# A working tree that isn't clean: refused.
|
|
exec touch repo/stray
|
|
! exec repo/scripts/publish.sh --local --dry-run
|
|
stderr '^publish: the working tree isn''t clean'
|
|
rm repo/stray
|
|
|
|
# A release that's already on GitHub, without this release's files:
|
|
# refused.
|
|
mkdir gh/release
|
|
exec touch gh/release/notes.txt
|
|
! exec repo/scripts/publish.sh --local --dry-run
|
|
stderr '^publish: devvm v1.2.3 already has a GitHub release, without devvm-1.2.3-darwin-arm64.tar.gz'
|
|
rm gh/release
|
|
|
|
# gh not logged in: refused.
|
|
exec touch gh/no-auth
|
|
! exec repo/scripts/publish.sh --local --dry-run
|
|
stderr '^publish: gh isn''t logged in to GitHub: run gh auth login$'
|
|
rm gh/no-auth
|
|
|
|
# No tap checkout: refused.
|
|
env DEVVM_TAP_DIR=$WORK/nowhere
|
|
! exec repo/scripts/publish.sh --local --dry-run
|
|
stderr '^publish: no tap checkout at '
|
|
env DEVVM_TAP_DIR=$WORK/tap
|
|
|
|
# None of those built anything.
|
|
! exists log
|
|
|
|
# --dry-run: everything it would publish, then nothing published: no
|
|
# push, no release, no tap commit.
|
|
rm calls
|
|
exec repo/scripts/publish.sh --local --dry-run
|
|
stdout '^Version: 1\.2\.3$'
|
|
stdout '^Tag: v1\.2\.3, signed, at commit [0-9a-f]{40}$'
|
|
stdout '^ devvm-1\.2\.3-linux-amd64\.tar\.gz +[0-9]+ bytes [0-9a-f]{64}$'
|
|
stdout '^ SHA256SUMS\.minisig +[0-9]+ bytes [0-9a-f]{64}$'
|
|
stdout '^ - \*\*New:\*\* a thing\.$'
|
|
! stdout 'Older'
|
|
stdout '^\+ url "https://github.com/devvmhq/devvm/releases/download/v1\.2\.3/devvm-1\.2\.3-darwin-arm64\.tar\.gz"$'
|
|
stdout '^Formula/devvm\.rb:$'
|
|
stdout '^Formula/devvm-rc\.rb, which the tap doesn''t have yet, for this release too:$'
|
|
stdout '^\+class DevvmRc < Formula$'
|
|
stdout '^ 1\. git push origin main: to do$'
|
|
stdout '^ 4\. the tap''s commit, devvm 1\.2\.3, and git push: to do$'
|
|
stdout '^--dry-run: nothing published\.$'
|
|
cmp calls calls.view
|
|
exec bash refs.sh
|
|
cmp stdout refs.before
|
|
exists repo/dist/SHA256SUMS.minisig
|
|
|
|
# The repo has no release keys, as devvm has none until they're made:
|
|
# the release is signed with the release key alone, as before them, and
|
|
# its install.sh trusts no release key.
|
|
exec minisign -Vm repo/dist/SHA256SUMS -p repo/packaging/minisign.pub
|
|
stdout 'Trusted comment: devvm 1\.2\.3'
|
|
! exists repo/dist/SHA256SUMS.ci.minisig
|
|
! exists repo/dist/SHA256SUMS.cosign.minisig
|
|
! exists repo/dist/SHA256SUMS.recovery.minisig
|
|
grep '^release_ci_key=$' repo/dist/install.sh
|
|
grep '^release_cosign_key=$' repo/dist/install.sh
|
|
grep '^release_recovery_key=$' repo/dist/install.sh
|
|
|
|
# The build's repository held the tag alone, though the repo has a stray
|
|
# one at the same commit.
|
|
grep '^release --clean --skip=publish tags=v1\.2\.3$' log
|
|
|
|
# --tag: the tag's build, as the release's, with the same checks, but not
|
|
# signed, so it matches the signed build's SHA256SUMS, and its install.sh
|
|
# trusts the release key. It never replaces the signed build's dist/.
|
|
cp repo/dist/SHA256SUMS signed.sums
|
|
! exec repo/scripts/release.sh --tag v1.2.3
|
|
stderr '^release: dist/ holds a signed build, which this unsigned one would replace: move it first, or set DEVVM_RELEASE_DIST to a new folder$'
|
|
exists repo/dist/SHA256SUMS.minisig
|
|
rm repo/dist
|
|
exec repo/scripts/release.sh --tag v1.2.3
|
|
stdout '^\(not signed: --tag builds the release without its signature\)$'
|
|
! exists repo/dist/SHA256SUMS.minisig
|
|
cmp repo/dist/SHA256SUMS signed.sums
|
|
exec bash -c 'grep -c "^minisign_key=\"$(sed -n 2p repo/packaging/minisign.pub)\"$" repo/dist/install.sh'
|
|
stdout '^1$'
|
|
exec bash tag.sh other v1.2.4
|
|
! exec repo/scripts/release.sh --tag v1.2.4
|
|
stderr '^release: tag v1\.2\.4 is signed by SHA256:\S+, not a key in packaging/release-signer$'
|
|
exec git -C repo tag -d v1.2.4
|
|
! exec repo/scripts/release.sh --tag 1.2.3
|
|
stderr '^release: --tag needs a release''s tag, v<version>, not ''1\.2\.3''$'
|
|
|
|
# Answering n: nothing published.
|
|
rm calls
|
|
ttyin -stdin no.txt
|
|
! exec repo/scripts/publish.sh --local
|
|
ttyout 'Publish devvm 1\.2\.3\? \[y/N\] '
|
|
stderr '^publish: nothing published$'
|
|
cmp calls calls.view
|
|
exec bash refs.sh
|
|
cmp stdout refs.before
|
|
|
|
# Answering y, with gh failing to make the release: main and the tag are
|
|
# pushed, in that order, and the rest is said to be left.
|
|
rm calls
|
|
exec touch gh/fail-create
|
|
ttyin -stdin yes.txt
|
|
! exec repo/scripts/publish.sh --local
|
|
stderr '^publish: the GitHub release v1\.2\.3 failed\.$'
|
|
stderr '^ published: main on origin$'
|
|
stderr '^ published: the tag v1\.2\.3 on origin$'
|
|
stderr '^ not published: the GitHub release v1\.2\.3$'
|
|
stderr '^ not published: the tap''s Formula/devvm\.rb and Formula/devvm-rc\.rb$'
|
|
! exists gh/release
|
|
|
|
# Run again, with gh failing to publish the draft: it skips the pushes and
|
|
# leaves a draft with every file, never published.
|
|
rm gh/fail-create
|
|
exec touch gh/fail-edit
|
|
ttyin -stdin yes.txt
|
|
! exec repo/scripts/publish.sh --local
|
|
stdout '^origin''s main is already at [0-9a-f]{12}$'
|
|
stdout '^origin already has v1\.2\.3$'
|
|
stderr '^ not published: the GitHub release v1\.2\.3$'
|
|
exists gh/draft
|
|
exists gh/release/SHA256SUMS.minisig
|
|
|
|
# And again: it uploads the draft's files again, publishes it, then commits
|
|
# the formulas to the tap, devvm's and devvm-rc's, and pushes it.
|
|
rm gh/fail-edit
|
|
ttyin -stdin yes.txt
|
|
exec repo/scripts/publish.sh --local
|
|
stdout '^ 3\. the GitHub release v1\.2\.3: to do, the draft''s files replaced$'
|
|
stdout '^==> devvm 1\.2\.3 is published$'
|
|
stdout '^Check it with Homebrew, brew update && brew upgrade devvm \(or brew trust --formula devvmhq/tap/devvm, then brew install devvmhq/tap/devvm\), or the install script:$'
|
|
stdout '^ curl -fsSL https://github.com/devvmhq/devvm/releases/download/v1\.2\.3/install\.sh \| bash$'
|
|
cmp calls calls.want
|
|
exec bash refs.sh
|
|
cmp stdout refs.after
|
|
exec bash -c 'cd gh/release && LC_ALL=C ls'
|
|
cmp stdout assets.want
|
|
! exists gh/draft
|
|
cmp gh/notes notes.want
|
|
cmp tap/Formula/devvm.rb repo/dist/devvm.rb
|
|
cmp tap/Formula/devvm-rc.rb repo/dist/devvm-rc.rb
|
|
exec git --git-dir=tap.git log -1 --format=%s main
|
|
stdout '^devvm 1\.2\.3$'
|
|
|
|
# And once more: everything's done, so it asks nothing.
|
|
rm calls
|
|
exec repo/scripts/publish.sh --local
|
|
stdout '^devvm 1\.2\.3 is already published: nothing to do\.$'
|
|
stdout '^Formula/devvm-rc\.rb:\n \(already this release''s\)$'
|
|
grep '^gh release download v1\.2\.3 ' calls
|
|
! grep 'push|create|edit' calls
|
|
|
|
# A prerelease, 1.3.0-rc.1: its GitHub release is marked as one, and its
|
|
# tap commit, devvm-rc 1.3.0-rc.1, moves only devvm-rc, so the formula
|
|
# devvm stays on 1.2.3. It needs the tap checkout too.
|
|
exec bash version.sh 1.3.0-rc.1 'A release candidate.' 'another thing'
|
|
rm gh/release
|
|
rm gh/notes
|
|
rm calls
|
|
env DEVVM_TAP_DIR=$WORK/nowhere
|
|
! exec repo/scripts/publish.sh --local --dry-run
|
|
stderr '^publish: no tap checkout at '
|
|
env DEVVM_TAP_DIR=$WORK/tap
|
|
exec repo/scripts/publish.sh --local --dry-run
|
|
stdout '^Version: 1\.3\.0-rc\.1, a prerelease$'
|
|
stdout '^Formula/devvm\.rb: stays on the last release, as this is a prerelease\.$'
|
|
stdout '^Formula/devvm-rc\.rb:$'
|
|
stdout '^\+ url "https://github.com/devvmhq/devvm/releases/download/v1\.3\.0-rc\.1/devvm-1\.3\.0-rc\.1-darwin-arm64\.tar\.gz"$'
|
|
! stdout '^\+class'
|
|
stdout '^ 3\. the GitHub prerelease v1\.3\.0-rc\.1: to do, marked as a prerelease$'
|
|
stdout '^ 4\. the tap''s commit, devvm-rc 1\.3\.0-rc\.1, and git push: to do$'
|
|
stdout '^ - \*\*New:\*\* another thing\.$'
|
|
! stdout 'Released today'
|
|
! exists repo/dist/devvm.rb
|
|
rm calls
|
|
ttyin -stdin yes.txt
|
|
exec repo/scripts/publish.sh --local
|
|
stdout '^==> devvm 1\.3\.0-rc\.1 is published$'
|
|
stdout '^Check it with Homebrew, brew update && brew upgrade devvm-rc \(or brew trust --formula devvmhq/tap/devvm-rc, then brew install devvmhq/tap/devvm-rc\), or the install script:$'
|
|
cmp calls calls.pre
|
|
exists gh/prerelease
|
|
cmp gh/notes notes.pre
|
|
exec git --git-dir=tap.git log -1 --format=%s main
|
|
stdout '^devvm-rc 1\.3\.0-rc\.1$'
|
|
exec git --git-dir=tap.git show --name-only --format= main
|
|
cmp stdout rc.changed
|
|
cmp tap/Formula/devvm-rc.rb repo/dist/devvm-rc.rb
|
|
grep 'download/v1\.2\.3/' tap/Formula/devvm.rb
|
|
|
|
# Run again: everything's done.
|
|
rm calls
|
|
exec repo/scripts/publish.sh --local
|
|
stdout '^devvm 1\.3\.0-rc\.1 is already published: nothing to do\.$'
|
|
! grep 'push|create|edit' calls
|
|
|
|
# A published prerelease that GitHub doesn't mark as one: refused.
|
|
rm gh/prerelease
|
|
! exec repo/scripts/publish.sh --local --dry-run
|
|
stderr '^publish: devvm v1\.3\.0-rc\.1 is a prerelease, but its GitHub release isn''t marked as one'
|
|
|
|
# A release older than devvm-rc's prerelease, 1.2.4: devvm moves to it,
|
|
# and devvm-rc stays on 1.3.0-rc.1.
|
|
exec bash version.sh 1.2.4 'A fix.' 'a fix'
|
|
rm gh/release
|
|
rm gh/notes
|
|
exec repo/scripts/publish.sh --local --dry-run
|
|
stdout '^Formula/devvm\.rb:$'
|
|
stdout '^Formula/devvm-rc\.rb: stays at 1\.3\.0-rc\.1, which is newer than 1\.2\.4\.$'
|
|
stdout '^ 4\. the tap''s commit, devvm 1\.2\.4, and git push: to do$'
|
|
rm calls
|
|
ttyin -stdin yes.txt
|
|
exec repo/scripts/publish.sh --local
|
|
stdout '^==> the tap''s Formula/devvm\.rb$'
|
|
exec git --git-dir=tap.git show --name-only --format= main
|
|
stdout '^Formula/devvm\.rb\n\z'
|
|
grep 'download/v1\.3\.0-rc\.1/' tap/Formula/devvm-rc.rb
|
|
|
|
# A prerelease older than devvm-rc's, 1.2.5-rc.1: nothing in the tap
|
|
# changes, so there's no tap step.
|
|
exec bash version.sh 1.2.5-rc.1 'An older candidate.' 'an older thing'
|
|
rm gh/release
|
|
rm gh/notes
|
|
exec repo/scripts/publish.sh --local --dry-run
|
|
stdout '^Formula/devvm-rc\.rb: stays at 1\.3\.0-rc\.1, which is newer than 1\.2\.5-rc\.1\.$'
|
|
stdout '^ 4\. the tap: nothing to change$'
|
|
rm calls
|
|
ttyin -stdin yes.txt
|
|
exec repo/scripts/publish.sh --local
|
|
stdout '^Check it with the install script, or devvm upgrade --to 1\.2\.5-rc\.1:$'
|
|
! grep 'push tap' calls
|
|
|
|
# The release 1.3.0, newer than devvm-rc's prerelease: devvm-rc moves to
|
|
# it with devvm, in one commit.
|
|
exec bash version.sh 1.3.0 'The release.' 'the release'
|
|
rm gh/release
|
|
rm gh/notes
|
|
rm gh/prerelease
|
|
exec repo/scripts/publish.sh --local --dry-run
|
|
stdout '^Formula/devvm-rc\.rb, which moves from 1\.3\.0-rc\.1 to this release too:$'
|
|
stdout '^\+ url "https://github.com/devvmhq/devvm/releases/download/v1\.3\.0/devvm-1\.3\.0-darwin-arm64\.tar\.gz"$'
|
|
rm calls
|
|
ttyin -stdin yes.txt
|
|
exec repo/scripts/publish.sh --local
|
|
exec git --git-dir=tap.git log -1 --format=%s main
|
|
stdout '^devvm 1\.3\.0$'
|
|
exec git --git-dir=tap.git show --name-only --format= main
|
|
cmp stdout both.changed
|
|
cmp tap/Formula/devvm.rb repo/dist/devvm.rb
|
|
cmp tap/Formula/devvm-rc.rb repo/dist/devvm-rc.rb
|
|
rm calls
|
|
exec repo/scripts/publish.sh --local
|
|
stdout '^devvm 1\.3\.0 is already published: nothing to do\.$'
|
|
! grep 'push|create|edit' calls
|
|
|
|
-- rc.changed --
|
|
Formula/devvm-rc.rb
|
|
-- both.changed --
|
|
Formula/devvm-rc.rb
|
|
Formula/devvm.rb
|
|
-- calls.pre --
|
|
gh auth status
|
|
gh release view v1.3.0-rc.1 --repo devvmhq/devvm --json isDraft,isPrerelease,assets --jq (.isDraft | tostring), (.isPrerelease | tostring), .assets[].name
|
|
push origin.git refs/heads/main
|
|
push origin.git refs/tags/v1.3.0-rc.1
|
|
gh release create v1.3.0-rc.1 --repo devvmhq/devvm --title devvm 1.3.0-rc.1 --notes-file notes.md --verify-tag --draft --prerelease devvm-1.3.0-rc.1-darwin-arm64.tar.gz devvm-1.3.0-rc.1-darwin-amd64.tar.gz devvm-1.3.0-rc.1-linux-arm64.tar.gz devvm-1.3.0-rc.1-linux-amd64.tar.gz devvm-1.3.0-rc.1.tar.gz SHA256SUMS SHA256SUMS.minisig install.sh
|
|
gh release edit v1.3.0-rc.1 --repo devvmhq/devvm --title devvm 1.3.0-rc.1 --notes-file notes.md --draft=false --prerelease
|
|
push tap.git refs/heads/main
|
|
-- notes.pre --
|
|
A release candidate.
|
|
|
|
- **New:** another thing.
|
|
-- no.txt --
|
|
n
|
|
-- yes.txt --
|
|
y
|
|
-- repo.sh --
|
|
# The repo (VERSION 1.2.3, a changelog, release.sh and publish.sh), its
|
|
# origin one commit behind, a stray tag at its HEAD, two SSH keys git
|
|
# trusts (good, which packaging/release-signer pins, and other), the
|
|
# release key, and the tap.
|
|
set -eu
|
|
mkdir -p repo/scripts repo/packaging/homebrew keys gh
|
|
cp "$DEVVM_REPO/scripts/release.sh" "$DEVVM_REPO/scripts/publish.sh" repo/scripts/
|
|
cp "$DEVVM_REPO/packaging/homebrew/devvm.rb" repo/packaging/homebrew/
|
|
echo 1.2.3 > repo/VERSION
|
|
printf 'module example.com/x\n\ngo 1.22\n' > repo/go.mod
|
|
echo dist/ > repo/.gitignore
|
|
printf '#!/bin/sh\nrelease_version=""\nminisign_key=""\nrelease_ci_key=\nrelease_cosign_key=\nrelease_recovery_key=\n' > repo/install.sh
|
|
bash tools.sh > repo/mise.lock
|
|
printf '# Changelog\n\n## 1.2.3\n\nReleased today.\n\n- **New:** a thing.\n\n## 1.2.2\n\nOlder.\n' > repo/CHANGELOG.md
|
|
for n in good other; do ssh-keygen -q -t ed25519 -N '' -C "$n" -f "keys/$n"; done
|
|
{ printf 'e@e %s\n' "$(cat keys/good.pub)"; printf 'e@e %s\n' "$(cat keys/other.pub)"; } > keys/allowed
|
|
printf '# the release signer\n%s\n' "$(ssh-keygen -lf keys/good.pub | awk '{ print $2 }')" > repo/packaging/release-signer
|
|
minisign -G -W -p repo/packaging/minisign.pub -s keys/release.key >/dev/null
|
|
git config --global user.email e@e
|
|
git config --global user.name e
|
|
git config --global gpg.format ssh
|
|
git config --global gpg.ssh.allowedSignersFile "$PWD/keys/allowed"
|
|
git config --global init.defaultBranch main
|
|
for r in origin tap; do
|
|
git init -q --bare "$r.git"
|
|
printf '#!/bin/sh\nwhile read -r o n r; do echo "push %s $r" >> "$WORK/calls"; done\n' "$r.git" > "$r.git/hooks/post-receive"
|
|
chmod 755 "$r.git/hooks/post-receive"
|
|
done
|
|
git init -q repo
|
|
git -C repo add -A
|
|
git -C repo commit -qm r
|
|
git -C repo remote add origin "$PWD/origin.git"
|
|
git -C repo push -q origin main
|
|
echo more > repo/more
|
|
git -C repo add more
|
|
git -C repo commit -qm 'release 1.2.3'
|
|
git -C repo tag v9.9.9
|
|
git init -q tap
|
|
echo tap > tap/README
|
|
git -C tap add -A
|
|
git -C tap commit -qm tap
|
|
git -C tap remote add origin "$PWD/tap.git"
|
|
git -C tap push -q origin main
|
|
rm -f calls
|
|
-- tools.sh --
|
|
# A mise.lock's go and goreleaser, for both Linux processors: tarballs of a
|
|
# go that does nothing and of bin/goreleaser, by file URL and SHA-256.
|
|
set -eu
|
|
mkdir -p tools/go/bin
|
|
printf '#!/bin/sh\n' > tools/go/bin/go
|
|
chmod 755 tools/go/bin/go
|
|
tar -czf tools/go.tar.gz -C tools go
|
|
tar -czf tools/goreleaser.tar.gz -C bin goreleaser
|
|
for t in go goreleaser; do
|
|
sum=$({ sha256sum "tools/$t.tar.gz" 2>/dev/null || shasum -a 256 "tools/$t.tar.gz"; } | cut -c1-64)
|
|
printf '[[tools.%s]]\nversion = "1.30.0"\n\n' "$t"
|
|
for p in linux-arm64 linux-x64; do
|
|
printf '[tools.%s."platforms.%s"]\nchecksum = "sha256:%s"\nurl = "file://%s"\n\n' "$t" "$p" "$sum" "$PWD/tools/$t.tar.gz"
|
|
done
|
|
done
|
|
-- bin/podman --
|
|
#!/bin/bash
|
|
# Rootless podman, here: --version and info say so, and run runs
|
|
# --entrypoint, then the command, with each -v's container folder replaced
|
|
# by its host folder, in -w's folder, with each -e's variable set.
|
|
set -eu
|
|
case $1 in
|
|
--version) echo 'podman version 5.6.0'; exit 0 ;;
|
|
info) echo true; exit 0 ;;
|
|
run) ;;
|
|
*) echo "podman: no fake for $*" >&2; exit 1 ;;
|
|
esac
|
|
shift
|
|
from=() to=() dir= entry=()
|
|
while [[ $1 == -* ]]; do
|
|
case $1 in
|
|
--rm) shift ;;
|
|
--platform | --user | --name | --security-opt | --cap-drop | --pids-limit | --memory | --network) shift 2 ;;
|
|
--entrypoint) entry=("$2"); shift 2 ;;
|
|
-v) IFS=: read -r h c _ <<<"$2"; from+=("$c"); to+=("$h"); shift 2 ;;
|
|
-w) dir=$2; shift 2 ;;
|
|
-e) export "${2?}"; shift 2 ;;
|
|
*) echo "podman: no fake for $1" >&2; exit 1 ;;
|
|
esac
|
|
done
|
|
shift
|
|
set -- ${entry[@]+"${entry[@]}"} "$@"
|
|
map() {
|
|
local a=$1 i
|
|
for i in "${!from[@]}"; do [[ $a != "${from[i]}"* ]] || a=${to[i]}${a#"${from[i]}"}; done
|
|
printf '%s' "$a"
|
|
}
|
|
args=()
|
|
for a in "$@"; do args+=("$(map "$a")"); done
|
|
cd "$(map "$dir")"
|
|
exec "${args[@]}"
|
|
-- tag.sh --
|
|
# Tag $2, v1.2.3 without it, (again), signed with key $1.
|
|
set -eu
|
|
t=${2:-v1.2.3}
|
|
git -C repo tag -d "$t" >/dev/null 2>&1 || true
|
|
git -C repo -c user.signingkey="$PWD/keys/$1" tag -s "$t" -m "$t"
|
|
-- version.sh --
|
|
# VERSION $1 and its changelog entry, $2 then a list item New: $3, over
|
|
# 1.2.3's, committed on main and tagged.
|
|
set -eu
|
|
echo "$1" > repo/VERSION
|
|
printf '# Changelog\n\n## %s\n\n%s\n\n- **New:** %s.\n\n## 1.2.3\n\nReleased today.\n' "$1" "$2" "$3" > repo/CHANGELOG.md
|
|
git -C repo commit -qam "release $1"
|
|
bash tag.sh good "v$1"
|
|
-- refs.sh --
|
|
# What origin and the tap hold: main's commit message, the tag, the tap's
|
|
# last commit, and whether it has the formula.
|
|
git --git-dir=origin.git log -1 --format=%s main
|
|
git --git-dir=origin.git tag -l
|
|
git --git-dir=tap.git log -1 --format=%s main
|
|
f=$(git --git-dir=tap.git ls-tree --name-only main Formula/ | paste -sd' ' -)
|
|
echo "formulas: ${f:-none}"
|
|
-- refs.before --
|
|
r
|
|
tap
|
|
formulas: none
|
|
-- refs.after --
|
|
release 1.2.3
|
|
v1.2.3
|
|
devvm 1.2.3
|
|
formulas: Formula/devvm-rc.rb Formula/devvm.rb
|
|
-- calls.view --
|
|
gh auth status
|
|
gh release view v1.2.3 --repo devvmhq/devvm --json isDraft,isPrerelease,assets --jq (.isDraft | tostring), (.isPrerelease | tostring), .assets[].name
|
|
-- calls.want --
|
|
gh auth status
|
|
gh release view v1.2.3 --repo devvmhq/devvm --json isDraft,isPrerelease,assets --jq (.isDraft | tostring), (.isPrerelease | tostring), .assets[].name
|
|
push origin.git refs/heads/main
|
|
push origin.git refs/tags/v1.2.3
|
|
gh release create v1.2.3 --repo devvmhq/devvm --title devvm 1.2.3 --notes-file notes.md --verify-tag --draft devvm-1.2.3-darwin-arm64.tar.gz devvm-1.2.3-darwin-amd64.tar.gz devvm-1.2.3-linux-arm64.tar.gz devvm-1.2.3-linux-amd64.tar.gz devvm-1.2.3.tar.gz SHA256SUMS SHA256SUMS.minisig install.sh
|
|
gh auth status
|
|
gh release view v1.2.3 --repo devvmhq/devvm --json isDraft,isPrerelease,assets --jq (.isDraft | tostring), (.isPrerelease | tostring), .assets[].name
|
|
gh release create v1.2.3 --repo devvmhq/devvm --title devvm 1.2.3 --notes-file notes.md --verify-tag --draft devvm-1.2.3-darwin-arm64.tar.gz devvm-1.2.3-darwin-amd64.tar.gz devvm-1.2.3-linux-arm64.tar.gz devvm-1.2.3-linux-amd64.tar.gz devvm-1.2.3.tar.gz SHA256SUMS SHA256SUMS.minisig install.sh
|
|
gh release edit v1.2.3 --repo devvmhq/devvm --title devvm 1.2.3 --notes-file notes.md --draft=false
|
|
gh auth status
|
|
gh release view v1.2.3 --repo devvmhq/devvm --json isDraft,isPrerelease,assets --jq (.isDraft | tostring), (.isPrerelease | tostring), .assets[].name
|
|
gh release upload v1.2.3 --repo devvmhq/devvm --clobber devvm-1.2.3-darwin-arm64.tar.gz devvm-1.2.3-darwin-amd64.tar.gz devvm-1.2.3-linux-arm64.tar.gz devvm-1.2.3-linux-amd64.tar.gz devvm-1.2.3.tar.gz SHA256SUMS SHA256SUMS.minisig install.sh
|
|
gh release edit v1.2.3 --repo devvmhq/devvm --title devvm 1.2.3 --notes-file notes.md --draft=false
|
|
push tap.git refs/heads/main
|
|
-- assets.want --
|
|
SHA256SUMS
|
|
SHA256SUMS.minisig
|
|
devvm-1.2.3-darwin-amd64.tar.gz
|
|
devvm-1.2.3-darwin-arm64.tar.gz
|
|
devvm-1.2.3-linux-amd64.tar.gz
|
|
devvm-1.2.3-linux-arm64.tar.gz
|
|
devvm-1.2.3.tar.gz
|
|
install.sh
|
|
-- notes.want --
|
|
Released today.
|
|
|
|
- **New:** a thing.
|
|
-- bin/gh --
|
|
#!/bin/bash
|
|
# A gh that logs each call to $WORK/calls (paths as their base names) and
|
|
# keeps one release in $WORK/gh: release/ its files, draft while it's a
|
|
# draft, prerelease once it's marked as one, notes its notes. Switches:
|
|
# gh/no-auth fails gh auth status,
|
|
# gh/fail-create gh release create, gh/fail-edit gh release edit.
|
|
set -eu
|
|
s=$WORK/gh
|
|
line=gh
|
|
for a in "$@"; do
|
|
[[ $a != /* && $a != dist/* ]] || a=${a##*/}
|
|
line+=" $a"
|
|
done
|
|
echo "$line" >> "$WORK/calls"
|
|
# files ARG…: what's left after the subcommand's options, copied into the
|
|
# release; the notes and the draft as they say.
|
|
files() {
|
|
while (($#)); do
|
|
case $1 in
|
|
--notes-file) cp "$2" "$s/notes"; shift 2 ;;
|
|
--repo | --title | --pattern | --dir | --json | --jq) shift 2 ;;
|
|
--draft) touch "$s/draft"; shift ;;
|
|
--draft=false) rm -f "$s/draft"; shift ;;
|
|
--prerelease) touch "$s/prerelease"; shift ;;
|
|
--*) shift ;;
|
|
*) cp "$1" "$s/release/"; shift ;;
|
|
esac
|
|
done
|
|
}
|
|
case "$1 $2" in
|
|
"auth status") [[ ! -e $s/no-auth ]] ;;
|
|
"release view")
|
|
[[ -d $s/release ]] || { echo "release not found" >&2; exit 1; }
|
|
if [[ -e $s/draft ]]; then echo true; else echo false; fi
|
|
if [[ -e $s/prerelease ]]; then echo true; else echo false; fi
|
|
ls "$s/release" ;;
|
|
"release create")
|
|
[[ ! -e $s/fail-create ]] || { echo "HTTP 502: Bad Gateway" >&2; exit 1; }
|
|
git --git-dir="$WORK/origin.git" rev-parse -q --verify "refs/tags/$3" >/dev/null || { echo "tag $3 doesn't exist in the repo" >&2; exit 1; }
|
|
[[ ! -d $s/release ]] || { echo "a release with the same tag name already exists: $3" >&2; exit 1; }
|
|
mkdir "$s/release"
|
|
shift 3; files "$@" ;;
|
|
"release upload" | "release edit")
|
|
[[ -d $s/release ]] || { echo "release not found" >&2; exit 1; }
|
|
[[ $2 != edit || ! -e $s/fail-edit ]] || { echo "HTTP 502: Bad Gateway" >&2; exit 1; }
|
|
shift 3; files "$@" ;;
|
|
"release download")
|
|
dir=
|
|
while (($#)); do [[ $1 == --dir ]] && dir=$2; shift; done
|
|
mkdir -p "$dir"
|
|
cp "$s/release/SHA256SUMS" "$dir/" ;;
|
|
*) echo "gh: no fake for $*" >&2; exit 1 ;;
|
|
esac
|
|
-- bin/goreleaser --
|
|
#!/bin/bash
|
|
# Logs its call and its repository's tags, and writes a dist/ like
|
|
# GoReleaser's, the same each time: each system's and processor's build, a
|
|
# script printing $DEVVM_VERSION, an archive for each (a line of text), the
|
|
# source tarball and SHA256SUMS.
|
|
set -eu
|
|
echo "$* tags=$(git tag -l | paste -sd, -)" >> "$WORK/log"
|
|
rm -rf dist
|
|
mkdir 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' "$DEVVM_VERSION" > "dist/devvm_${os}_$a/devvm"
|
|
chmod 755 "dist/devvm_${os}_$a/devvm"
|
|
echo "devvm $DEVVM_VERSION $os $a" > "dist/devvm-$DEVVM_VERSION-$os-$a.tar.gz"
|
|
done
|
|
done
|
|
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)
|