4 # ./make-release --dry-run|--real <branch>
6 # ./make-release --dry-run main
9 # Overall release steps:
11 # - ensure pretest == tested == main
14 # - make deploy and test that chiark still works
16 # - release announcement to mailing list
19 #---------- argument parsing and options ----------
24 fail () { echo >&2 "${0##*/}: error: $*"; exit 12; }
26 dryrun=x-dry-run-unset
27 cargo_dryrun=--not-a-cargo-option-please-crash
30 2.--real) dryrun=x ; cargo_dryrun='' ; ;;
31 2.--dry-run) dryrun=dryrun; cargo_dryrun='--dry-run'; ;;
32 *) fail "bad usage" ;;
35 keyid=0x559AE46C2D6B6D3265E7CBA1E3E3392348B50D39
38 https://raw.githubusercontent.com/rust-lang/crates.io-index/master
42 dryrun () { echo "WOULD $*"; }
43 x () { echo >&2 "+ $*"; "$@"; }
46 trouble () { echo >&2 "***TROUBLE***: $*"; trouble=true; }
48 #---------- checks ----------
50 version=$(perl <Cargo.toml -ne '
51 next unless m{^version\s*=\s*\"([0-9.]+)\"\s*$};
52 print "$1\n" or die $!;
57 '') fail "no version?" ;;
60 echo "version $version"
63 diff <(git rev-parse refs/heads/$1) <(git rev-parse HEAD) \
64 || trouble "HEAD not equal to $1"
70 bad=$(git status --porcelain)
71 if [ "x$bad" != x ]; then
72 printf >&2 '%s\n' "$bad"
73 trouble 'tree is dirty'
77 tag_exists=$(git for-each-ref "[r]efs/tags/$tag")
78 if [ "x$tag_exists" != x ]; then trouble "tag $tag already exists"; fi
80 head -1 CHANGELOG.md | grep "^Version $version" \
81 || trouble "CHANGELOG.md not updated"
83 cargo_order='base . cli daemon wasm apitest wdriver'
84 missing=(git ls-files :\*/Cargo.toml :Cargo.toml)
85 for x in $cargo_order; do missing+=(:!$x/Cargo.toml); done
86 missing=$( "${missing[@]}" )
87 if [ "x$missing" != x ]; then trouble "missing cargo package(s) $missing"; fi
89 #---------- end of checks ----------
92 $dryrun fail "trouble! checks failed!"
97 #---------- actually do the work ----------
99 $dryrun git push chiark $branch
100 $dryrun git push origin $branch
102 #---------- non-idempotent things ----------
104 $dryrun make -j12 publish
106 $dryrun git tag -s -u "$keyid" -m "Otter v$version" $tag
107 $dryrun git push chiark $tag
108 $dryrun git push origin $tag
110 #---------- oh woe cargo ----------
112 # https://github.com/rust-lang/cargo/issues/9507
113 wait_for_crates_io () {
116 local url="$cratesio_raw_url/${p:0:2}/${p:2:2}/$p"
117 printf >&2 "waiting for upload of %s to take effect" "$p"
118 while sleep $delay; do
121 curl -sS "$url" | jq '.vers | select(. == "'"$version"'")'
123 if [ "x$got" != x ]; then break; fi
124 delay=$(( $delay * 11 / 10 + 1 ))
129 for cargo_dir in $cargo_order; do
130 $dryrun_no_more_cargo \
131 nailing-cargo --no-nail --linkfarm=git --- \
133 find . ! -type l ! -type d ! -path './target/*' -print0 \
135 cd $cargo_dir; cargo publish $cargo_dryrun
139 sed -n '/^name *=/ { s/^name *= *"\(.*\)" *$/\1/; p; q }' \
140 <$cargo_dir/Cargo.toml
143 wait_for_crates_io "$cargo_package"
145 dryrun_no_more_cargo=$dryrun
149 #---------- finish ----------
154 Successfully released to
162 You need to write release announcements
163 - sgo-software-announce