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]>
425 lines
21 KiB
Bash
Executable File
425 lines
21 KiB
Bash
Executable File
#!/bin/bash
|
|
# Release the version VERSION names, after git tag -s v<version> on main's HEAD. CI's Release workflow
|
|
# builds and signs it, and the co-signer rebuilds it, signs it and publishes it, with the tap
|
|
# (docs/content/docs/contributing/maintaining.md):
|
|
# scripts/publish.sh check the tag, show what it pushes, ask once, then push main and the
|
|
# tag to origin, which starts CI's Release workflow, and say what's next
|
|
# scripts/publish.sh --sign-legacy
|
|
# while releases bridge from the old release key: VERSION's draft
|
|
# release, which the co-signer made, has its SHA256SUMS checked against
|
|
# CI's and the co-signer's signatures and signed with the old key
|
|
# (scripts/release.sh --sign-legacy, which asks for its password), then,
|
|
# after asking once, SHA256SUMS.minisig is uploaded to the draft, and the
|
|
# co-signer publishes the release at its next run
|
|
# scripts/publish.sh --local the release built, signed with the old key alone and published from
|
|
# this machine, as before CI and the co-signer, for as long as their
|
|
# GitHub setup isn't done (docs/content/docs/contributing/github-setup.md)
|
|
# --dry-run with any of them, everything up to the question: nothing is pushed,
|
|
# uploaded or published, and the tap gets no commit
|
|
# scripts/publish.sh --help this
|
|
# Without --local, it needs git alone, and --sign-legacy needs gh, logged in, and minisign. Both refuse
|
|
# a tag whose commit has no release keys in packaging/keys, which CI's workflow refuses, and say where
|
|
# making them is described (docs/content/docs/contributing/github-setup.md, step 1); --local doesn't
|
|
# need them, and signs with the old release key alone while there are none.
|
|
# --local builds dist/ (scripts/release.sh, which asks for the minisign password), shows what it
|
|
# publishes, asks once, then publishes: it pushes main and the tag to origin, makes the GitHub release devvmhq/devvm v<version> with the archives,
|
|
# the source tarball, SHA256SUMS, SHA256SUMS.minisig and install.sh, its notes CHANGELOG.md's entry, then
|
|
# commits dist/devvm.rb to the tap's Formula/devvm.rb, and dist/devvm-rc.rb to its Formula/devvm-rc.rb when
|
|
# the tap's devvm-rc is older, so devvm-rc's users get the release too, and pushes the tap. Each step skips
|
|
# what's already done, so after a failure, fix it and run it again.
|
|
# A prerelease (VERSION x.y.z-rc.N, such as 0.2.0-rc.1) gets a GitHub release marked as a prerelease, which
|
|
# GitHub's latest release, and so install.sh's default and devvm upgrade, skips. Its tap commit,
|
|
# devvm-rc <version>, changes only Formula/devvm-rc.rb, when the tap's devvm-rc is older, so the formula
|
|
# devvm stays on the last release.
|
|
# DEVVM_TAP_DIR: the checkout of devvmhq/homebrew-tap, clean and on main (default ../homebrew-tap, next to
|
|
# this repo). DEVVM_MINISIGN_KEY: the release key (scripts/release.sh's).
|
|
# Needs gh, logged in (gh auth login), and release.sh's podman or Docker, curl and minisign:
|
|
# mise exec -- scripts/publish.sh.
|
|
set -euo pipefail
|
|
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$root"
|
|
repo=devvmhq/devvm
|
|
die() { echo "publish: $*" >&2; exit 1; }
|
|
usage() { awk 'NR > 1 && /^#/ { sub(/^# ?/, ""); print; next } NR > 1 { exit }' "$root/scripts/publish.sh"; }
|
|
|
|
dry=false mode=
|
|
for a in "$@"; do
|
|
case $a in
|
|
--dry-run) dry=true ;;
|
|
--local | --sign-legacy)
|
|
[[ -z $mode || $mode == "$a" ]] || { echo "publish: $mode and $a are two modes: give one" >&2; exit 2; }
|
|
mode=$a ;;
|
|
-h | --help) usage; exit 0 ;;
|
|
*) echo "publish: unknown argument '$a'" >&2; usage >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
|
|
v=$(tr -d '[:space:]' < VERSION)
|
|
tag=v$v
|
|
# A prerelease's version has a -suffix (release.sh checks its form): its release is marked as one.
|
|
pre=false pre_flag=()
|
|
if [[ $v == *-* ]]; then pre=true pre_flag=(--prerelease); fi
|
|
# remote_ref DIR REF: the object REF names on DIR's origin, "" when it has none.
|
|
remote_ref() {
|
|
local out
|
|
out=$(git -C "$1" ls-remote origin "$2") || return 1
|
|
awk -v r="$2" '$2 == r { print $1 }' <<<"$out"
|
|
}
|
|
sha256() { { sha256sum "$1" 2>/dev/null || shasum -a 256 "$1"; } | cut -c1-64; }
|
|
# formula_version FILE: the release the formula FILE installs, from its first URL
|
|
# (releases/download/v<version>/); "" for no file or none it names as release.sh writes versions.
|
|
formula_version() {
|
|
local got
|
|
[[ -f $1 ]] || return 0
|
|
got=$(sed -n 's|.*/releases/download/v\([^/"]*\)/.*|\1|p' "$1" | head -n1)
|
|
[[ $got =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+\.[0-9]+)?$ ]] && echo "$got"
|
|
return 0
|
|
}
|
|
# newer A B: whether version A is newer than version B, both x.y.z or x.y.z-<word>.N (release.sh's
|
|
# forms): numbers as numbers, a prerelease before its release, words as text, then their numbers.
|
|
newer() {
|
|
local a b i ap=0 bp=0
|
|
IFS=.- read -r -a a <<<"$1"
|
|
IFS=.- read -r -a b <<<"$2"
|
|
for i in 0 1 2; do
|
|
((10#${a[i]} == 10#${b[i]})) || { ((10#${a[i]} > 10#${b[i]})); return; }
|
|
done
|
|
[[ $1 == *-* ]] && ap=1
|
|
[[ $2 == *-* ]] && bp=1
|
|
((ap == bp)) || { ((ap < bp)); return; }
|
|
((ap)) || return 1
|
|
[[ ${a[3]} == "${b[3]}" ]] || { [[ ${a[3]} > ${b[3]} ]]; return; }
|
|
((10#${a[4]} > 10#${b[4]}))
|
|
}
|
|
|
|
# needs_gh: gh, logged in, and minisign, which every mode but the default needs.
|
|
needs_gh() {
|
|
command -v gh >/dev/null || die "needs gh, GitHub's command line (brew install gh)"
|
|
gh auth status >/dev/null 2>&1 || die "gh isn't logged in to GitHub: run gh auth login"
|
|
command -v minisign >/dev/null || die "needs minisign (mise exec -- scripts/publish.sh)"
|
|
}
|
|
# check_tag CHECK: the tag exists, is signed, and by a key in packaging/release-signer, by release.sh's
|
|
# own checks, CHECK (--check, or --check-tag, which needs no container runtime); its commit is main's
|
|
# HEAD, origin's main is an ancestor of it, and origin has no other tag of its name. It sets commit,
|
|
# tagobj, origin_main and origin_tag.
|
|
check_tag() {
|
|
local main
|
|
commit=$(scripts/release.sh "$1") || exit 1
|
|
main=$(git rev-parse -q --verify refs/heads/main) || die "no branch main"
|
|
[[ $main == "$commit" ]] || die "tag $tag is at ${commit:0:12}, not main's HEAD (${main:0:12}): tag main's HEAD"
|
|
tagobj=$(git rev-parse "refs/tags/$tag")
|
|
origin_main=$(remote_ref . refs/heads/main) || die "can't read origin (git ls-remote origin)"
|
|
if [[ -n $origin_main && $origin_main != "$commit" ]]; then
|
|
git merge-base --is-ancestor "$origin_main" "$commit" 2>/dev/null ||
|
|
die "origin's main has commits main lacks: pull, then tag main's HEAD again"
|
|
fi
|
|
origin_tag=$(remote_ref . "refs/tags/$tag") || die "can't read origin (git ls-remote origin)"
|
|
[[ -z $origin_tag || $origin_tag == "$tagobj" ]] ||
|
|
die "origin has another tag $tag: this one is $tagobj, origin's $origin_tag"
|
|
}
|
|
# notes FILE: the release's notes, the tag's CHANGELOG.md entry ## <version>, in FILE, without the
|
|
# heading or the blank lines at either end; FILE is empty for no entry.
|
|
notes() {
|
|
git show "$commit:CHANGELOG.md" | awk -v h="## $v" '
|
|
$0 == h { on = 1; next }
|
|
on && /^## / { exit }
|
|
on && NF { if (started) for (; blank > 0; blank--) print ""; print; started = 1; blank = 0; next }
|
|
on { blank++ }' > "$1"
|
|
}
|
|
# ask QUESTION REFUSED: QUESTION on the terminal, [y/N]; any answer but y stops it, saying REFUSED.
|
|
ask() {
|
|
local answer=
|
|
{ : </dev/tty; } 2>/dev/null || die "no terminal to ask on: $2"
|
|
printf '%s [y/N] ' "$1" >/dev/tty
|
|
read -r answer </dev/tty || true
|
|
[[ $answer == y || $answer == Y ]] || die "$2"
|
|
}
|
|
|
|
# push_tag: the default mode, the maintainer's part of a release that CI builds and the co-signer
|
|
# publishes: the tag's checks, then main and the tag pushed to origin, and what comes next.
|
|
push_tag() {
|
|
local done_main=false done_tag=false tmp
|
|
[[ -z $(git status --porcelain) ]] || die "the working tree isn't clean: commit or remove what git status lists"
|
|
check_tag --check-tag
|
|
# CI's workflow builds only a commit with the three release keys, which its devvm checks CI's and
|
|
# the co-signer's signatures with.
|
|
git cat-file -e "$commit:packaging/keys/release-ci.pub" 2>/dev/null ||
|
|
die "$tag's commit has no release keys in packaging/keys, so CI's Release workflow refuses it: make them first (docs/content/docs/contributing/github-setup.md, step 1), or publish it from this machine with --local"
|
|
# The co-signer takes the release's notes from the changelog.
|
|
tmp=$(mktemp "${TMPDIR:-/tmp}/devvm-publish.XXXXXX")
|
|
notes "$tmp"
|
|
[[ -s $tmp ]] || { rm -f "$tmp"; die "CHANGELOG.md has no entry ## $v: nothing pushed"; }
|
|
rm -f "$tmp"
|
|
[[ $origin_main != "$commit" ]] || done_main=true
|
|
[[ $origin_tag != "$tagobj" ]] || done_tag=true
|
|
echo
|
|
echo "==> devvm $v, to push"
|
|
if $pre; then echo "Version: $v, a prerelease"; else echo "Version: $v"; fi
|
|
echo "Tag: $tag, signed, at commit $commit"
|
|
echo
|
|
echo "Steps:"
|
|
echo " 1. git push origin main: $(state $done_main "to do")"
|
|
echo " 2. git push origin $tag: $(state $done_tag "to do")"
|
|
echo
|
|
if $done_main && $done_tag; then
|
|
echo "$tag and main are already on origin: nothing to push."
|
|
else
|
|
if $dry; then echo "--dry-run: nothing pushed."; exit 0; fi
|
|
ask "Push main and $tag to origin?" "nothing pushed"
|
|
$done_main || git push origin main
|
|
$done_tag || git push origin "refs/tags/$tag"
|
|
echo
|
|
echo "==> $tag is on origin. What comes next:"
|
|
fi
|
|
echo " 1. Approve the Release workflow's run for $tag in its release environment, at https://github.com/$repo/actions/workflows/release.yml."
|
|
echo " 2. Within the hour, the co-signer rebuilds it, signs it and makes its draft release, or tells you why not."
|
|
echo " 3. While releases bridge from the old release key, sign the draft's SHA256SUMS with it: scripts/publish.sh --sign-legacy."
|
|
echo " 4. At its next run, the co-signer publishes the release and updates the tap."
|
|
}
|
|
|
|
# sign_legacy: --sign-legacy, the old release key's signature on the co-signer's draft of VERSION's
|
|
# release, checked against CI's and the co-signer's signatures first, then uploaded.
|
|
sign_legacy() {
|
|
# tmp isn't local: the trap reads it once sign_legacy has returned.
|
|
local out assets f
|
|
needs_gh
|
|
if ! out=$(gh release view "$tag" --repo "$repo" --json isDraft,assets --jq '(.isDraft | tostring), .assets[].name' 2>&1); then
|
|
grep -qi 'not found' <<<"$out" || die "can't read the GitHub release $tag (gh release view): $out"
|
|
die "devvm $tag has no draft release yet: the co-signer makes it once CI's build and its own match"
|
|
fi
|
|
[[ $(head -n1 <<<"$out") == true ]] || die "devvm $tag's GitHub release is already published"
|
|
assets=$(tail -n +2 <<<"$out")
|
|
if grep -qxF SHA256SUMS.minisig <<<"$assets"; then
|
|
echo "devvm $tag's draft already has SHA256SUMS.minisig: nothing to do. The co-signer publishes it at its next run."
|
|
return 0
|
|
fi
|
|
for f in SHA256SUMS SHA256SUMS.ci.minisig SHA256SUMS.cosign.minisig; do
|
|
grep -qxF "$f" <<<"$assets" ||
|
|
die "devvm $tag's draft has no $f yet: the co-signer uploads it with its signature, so wait for its next run"
|
|
done
|
|
tmp=$(mktemp -d "${TMPDIR:-/tmp}/devvm-publish.XXXXXX")
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
gh release download "$tag" --repo "$repo" --dir "$tmp" --pattern SHA256SUMS --pattern SHA256SUMS.ci.minisig \
|
|
--pattern SHA256SUMS.cosign.minisig >/dev/null || die "can't download the draft's SHA256SUMS and its signatures: nothing signed or uploaded"
|
|
scripts/release.sh --sign-legacy "$tmp" || die "nothing signed or uploaded"
|
|
echo
|
|
echo "==> devvm $v's SHA256SUMS, which CI and the co-signer signed, signed with the old release key:"
|
|
sed 's/^/ /' "$tmp/SHA256SUMS"
|
|
echo
|
|
if $dry; then echo "--dry-run: nothing uploaded."; exit 0; fi
|
|
ask "Upload SHA256SUMS.minisig to devvm $v's draft release?" "nothing uploaded"
|
|
gh release upload "$tag" --repo "$repo" "$tmp/SHA256SUMS.minisig" ||
|
|
die "the upload failed: run scripts/publish.sh --sign-legacy again"
|
|
echo "==> uploaded: the co-signer publishes devvm $v at its next run, within the hour."
|
|
}
|
|
state() { if $1; then echo "done"; else echo "$2"; fi; }
|
|
|
|
case $mode in
|
|
"") push_tag; exit 0 ;;
|
|
--sign-legacy) sign_legacy; exit 0 ;;
|
|
esac
|
|
|
|
# --local: the preconditions, before anything asks for the password.
|
|
[[ -z $(git status --porcelain) ]] || die "the working tree isn't clean: commit or remove what git status lists"
|
|
needs_gh
|
|
check_tag --check
|
|
|
|
files=()
|
|
for os in darwin linux; do
|
|
for arch in arm64 amd64; do files+=("devvm-$v-$os-$arch.tar.gz"); done
|
|
done
|
|
files+=("devvm-$v.tar.gz" SHA256SUMS SHA256SUMS.minisig install.sh)
|
|
# The release: none yet, a draft (a run that stopped while uploading: its files are replaced), or
|
|
# published (a run that stopped later: it needs every file, and to be a prerelease just when this is one).
|
|
release=none
|
|
if out=$(gh release view "$tag" --repo "$repo" --json isDraft,isPrerelease,assets --jq '(.isDraft | tostring), (.isPrerelease | tostring), .assets[].name' 2>&1); then
|
|
release=published
|
|
[[ $(head -n1 <<<"$out") != true ]] || release=draft
|
|
if [[ $release == published ]]; then
|
|
for f in "${files[@]}"; do
|
|
tail -n +3 <<<"$out" | grep -qxF "$f" ||
|
|
die "devvm $tag already has a GitHub release, without $f: finish it or delete it by hand (gh release view $tag --repo $repo)"
|
|
done
|
|
marked=$(sed -n 2p <<<"$out")
|
|
if $pre && [[ $marked != true ]]; then
|
|
die "devvm $tag is a prerelease, but its GitHub release isn't marked as one: mark it by hand (gh release edit $tag --repo $repo --prerelease)"
|
|
elif ! $pre && [[ $marked == true ]]; then
|
|
die "devvm $tag's GitHub release is marked as a prerelease: unmark it by hand (gh release edit $tag --repo $repo --prerelease=false)"
|
|
fi
|
|
fi
|
|
elif ! grep -qi 'not found' <<<"$out"; then
|
|
die "can't read the GitHub release $tag (gh release view): $out"
|
|
fi
|
|
|
|
# The tap.
|
|
tap=${DEVVM_TAP_DIR:-$(dirname "$root")/homebrew-tap}
|
|
[[ -d $tap ]] && top=$(git -C "$tap" rev-parse --show-toplevel 2>/dev/null) && [[ $top == "$(cd "$tap" && pwd -P)" ]] ||
|
|
die "no tap checkout at $tap: clone devvmhq/homebrew-tap there, or set DEVVM_TAP_DIR"
|
|
[[ $(git -C "$tap" symbolic-ref -q --short HEAD) == main ]] || die "the tap at $tap isn't on main"
|
|
[[ -z $(git -C "$tap" status --porcelain) ]] || die "the tap at $tap isn't clean: commit or remove what git status lists"
|
|
tap_origin=$(remote_ref "$tap" refs/heads/main) || die "can't read the tap's origin (git -C $tap ls-remote origin)"
|
|
tap_head=$(git -C "$tap" rev-parse HEAD)
|
|
if [[ -n $tap_origin && $tap_origin != "$tap_head" ]]; then
|
|
git -C "$tap" merge-base --is-ancestor "$tap_origin" "$tap_head" 2>/dev/null ||
|
|
die "the tap's origin has commits its main lacks: git -C $tap pull"
|
|
fi
|
|
# The tap's formulas this release writes: devvm.rb for a release, and devvm-rc.rb unless the tap's
|
|
# devvm-rc is newer than this, so devvm-rc only moves forward, to a prerelease or a release.
|
|
rc_was=$(formula_version "$tap/Formula/devvm-rc.rb")
|
|
rc_moves=true
|
|
if [[ -n $rc_was ]] && newer "$rc_was" "$v"; then rc_moves=false; fi
|
|
tap_files=()
|
|
$pre || tap_files+=(devvm.rb)
|
|
! $rc_moves || tap_files+=(devvm-rc.rb)
|
|
tap_msg="devvm $v"
|
|
$pre && tap_msg="devvm-rc $v"
|
|
|
|
# The build, from the tag. minisign asks for the password.
|
|
scripts/release.sh || die "scripts/release.sh failed: nothing published"
|
|
for f in "${files[@]}" ${tap_files[@]+"${tap_files[@]}"}; do [[ -f dist/$f ]] || die "dist/ has no $f: nothing published"; done
|
|
tmp=$(mktemp -d "${TMPDIR:-/tmp}/devvm-publish.XXXXXX")
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
notes=$tmp/notes.md
|
|
notes "$notes"
|
|
[[ -s $notes ]] || die "CHANGELOG.md has no entry ## $v: nothing published"
|
|
# A published release is this build's only if its SHA256SUMS is dist/'s.
|
|
if [[ $release == published ]]; then
|
|
gh release download "$tag" --repo "$repo" --pattern SHA256SUMS --dir "$tmp/published" >/dev/null ||
|
|
die "can't download the GitHub release's SHA256SUMS: nothing published"
|
|
cmp -s "$tmp/published/SHA256SUMS" dist/SHA256SUMS ||
|
|
die "devvm $tag is already published from another build: its SHA256SUMS isn't dist/'s, so finish it by hand"
|
|
fi
|
|
|
|
done_main=false done_tag=false done_release=false done_tap=false
|
|
[[ $origin_main != "$commit" ]] || done_main=true
|
|
[[ $origin_tag != "$tagobj" ]] || done_tag=true
|
|
[[ $release != published ]] || done_release=true
|
|
if ((${#tap_files[@]})); then
|
|
done_tap=true
|
|
[[ $tap_origin == "$tap_head" ]] || done_tap=false
|
|
for f in "${tap_files[@]}"; do cmp -s "$tap/Formula/$f" "dist/$f" || done_tap=false; done
|
|
else
|
|
done_tap=true
|
|
fi
|
|
|
|
echo
|
|
echo "==> devvm $v, to publish"
|
|
kind=release
|
|
$pre && kind=prerelease
|
|
if $pre; then echo "Version: $v, a prerelease"; else echo "Version: $v"; fi
|
|
echo "Tag: $tag, signed, at commit $commit"
|
|
echo
|
|
echo "Files, from dist/, for the GitHub $kind $repo $tag:"
|
|
for f in "${files[@]}"; do printf ' %-34s %10s bytes %s\n' "$f" "$(wc -c < "dist/$f" | tr -d ' ')" "$(sha256 "dist/$f")"; done
|
|
echo
|
|
echo "Release notes, CHANGELOG.md's ## $v:"
|
|
sed 's/^/ /' "$notes"
|
|
echo
|
|
echo "Tap, $tap:"
|
|
$pre && echo "Formula/devvm.rb: stays on the last release, as this is a prerelease."
|
|
for f in ${tap_files[@]+"${tap_files[@]}"}; do
|
|
if [[ $f == devvm-rc.rb && $rc_was != "$v" ]] && ! $pre; then
|
|
if [[ -n $rc_was ]]; then
|
|
echo "Formula/devvm-rc.rb, which moves from $rc_was to this release too:"
|
|
else
|
|
echo "Formula/devvm-rc.rb, which the tap doesn't have yet, for this release too:"
|
|
fi
|
|
else
|
|
echo "Formula/$f:"
|
|
fi
|
|
old=$tap/Formula/$f
|
|
[[ -f $old ]] || old=/dev/null
|
|
git -C "$tap" diff --no-index -- "$old" "$root/dist/$f" || true
|
|
if cmp -s "$old" "dist/$f"; then echo " (already this release's)"; fi
|
|
done
|
|
$rc_moves || echo "Formula/devvm-rc.rb: stays at $rc_was, which is newer than $v."
|
|
echo
|
|
echo "Steps:"
|
|
echo " 1. git push origin main: $(state $done_main "to do")"
|
|
echo " 2. git push origin $tag: $(state $done_tag "to do")"
|
|
todo="to do"
|
|
[[ $release != draft ]] || todo="to do, the draft's files replaced"
|
|
$pre && todo="$todo, marked as a prerelease"
|
|
echo " 3. the GitHub $kind $tag: $(state $done_release "$todo")"
|
|
if ((${#tap_files[@]})); then
|
|
echo " 4. the tap's commit, $tap_msg, and git push: $(state $done_tap "to do")"
|
|
else
|
|
echo " 4. the tap: nothing to change"
|
|
fi
|
|
echo
|
|
|
|
check() {
|
|
local formula=devvm
|
|
$pre && formula=devvm-rc
|
|
if $pre && ! $rc_moves; then
|
|
echo "Check it with the install script, or devvm upgrade --to $v:"
|
|
else
|
|
echo "Check it with Homebrew, brew update && brew upgrade $formula (or brew trust --formula devvmhq/tap/$formula, then brew install devvmhq/tap/$formula), or the install script:"
|
|
fi
|
|
echo " curl -fsSL https://github.com/devvmhq/devvm/releases/download/$tag/install.sh | bash"
|
|
}
|
|
if $done_main && $done_tag && $done_release && $done_tap; then
|
|
echo "devvm $v is already published: nothing to do."
|
|
check
|
|
exit 0
|
|
fi
|
|
if $dry; then echo "--dry-run: nothing published."; exit 0; fi
|
|
|
|
ask "Publish devvm $v?" "nothing published"
|
|
|
|
step_main() {
|
|
$done_main && { echo "origin's main is already at ${commit:0:12}"; return 0; }
|
|
git push origin main
|
|
}
|
|
step_tag() {
|
|
$done_tag && { echo "origin already has $tag"; return 0; }
|
|
git push origin "refs/tags/$tag"
|
|
}
|
|
step_release() {
|
|
$done_release && { echo "the GitHub release $tag is already published"; return 0; }
|
|
local paths=() f
|
|
for f in "${files[@]}"; do paths+=("dist/$f"); done
|
|
# A draft first, published once every file is uploaded: one that stops halfway is never seen.
|
|
if [[ $release == draft ]]; then
|
|
gh release upload "$tag" --repo "$repo" --clobber "${paths[@]}" || return 1
|
|
else
|
|
gh release create "$tag" --repo "$repo" --title "devvm $v" --notes-file "$notes" --verify-tag --draft \
|
|
${pre_flag[@]+"${pre_flag[@]}"} "${paths[@]}" || return 1
|
|
fi
|
|
gh release edit "$tag" --repo "$repo" --title "devvm $v" --notes-file "$notes" --draft=false ${pre_flag[@]+"${pre_flag[@]}"}
|
|
}
|
|
step_tap() {
|
|
$done_tap && { echo "the tap is already at $tap_msg"; return 0; }
|
|
local f changed=()
|
|
for f in "${tap_files[@]}"; do
|
|
cmp -s "$tap/Formula/$f" "dist/$f" && continue
|
|
mkdir -p "$tap/Formula" && cp "dist/$f" "$tap/Formula/$f" || return 1
|
|
changed+=("Formula/$f")
|
|
done
|
|
if ((${#changed[@]})); then
|
|
git -C "$tap" add "${changed[@]}" && git -C "$tap" commit -q -m "$tap_msg" || return 1
|
|
fi
|
|
git -C "$tap" push origin main
|
|
}
|
|
names=(main tag release)
|
|
labels=("main on origin" "the tag $tag on origin" "the GitHub $kind $tag")
|
|
if ((${#tap_files[@]})); then
|
|
names+=(tap)
|
|
labels+=("the tap's Formula/${tap_files[0]}${tap_files[1]:+ and Formula/${tap_files[1]}}")
|
|
fi
|
|
for i in "${!names[@]}"; do
|
|
echo "==> ${labels[$i]}"
|
|
if ! "step_${names[$i]}"; then
|
|
{
|
|
echo "publish: ${labels[$i]} failed."
|
|
if ((i > 0)); then printf ' published: %s\n' "${labels[@]:0:i}"; fi
|
|
printf ' not published: %s\n' "${labels[@]:i}"
|
|
echo "Fix what failed, then run scripts/publish.sh --local again, which skips what's done, or finish by hand (docs/content/docs/contributing/maintaining.md)."
|
|
} >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
echo
|
|
echo "==> devvm $v is published"
|
|
check
|