4 # ./make-release --dry-run|--real <branch>
6 # ./make-release --dry-run main
9 # Overall release steps:
11 # - update dependencies (cargo update, cargo upgrades)
12 # - update our Nightly rust and do a test build, note in build.rst
15 # - ensure pretest == tested == main
16 # - make deploy and test that chiark still works
18 # - release announcement to mailing list
21 #---------- argument parsing and options ----------
26 fail () { echo >&2 "${0##*/}: error: $*"; exit 12; }
28 dryrun=x-dry-run-unset
29 cargo_dryrun=--not-a-cargo-option-please-crash
32 2.--real) dryrun=x ; cargo_dryrun='' ; ;;
33 2.--dry-run) dryrun=dryrun; cargo_dryrun='--dry-run'; ;;
34 *) fail "bad usage" ;;
37 keyid=0x559AE46C2D6B6D3265E7CBA1E3E3392348B50D39
40 https://raw.githubusercontent.com/rust-lang/crates.io-index/master
44 dryrun () { echo "WOULD $*"; }
45 x () { echo >&2 "+ $*"; "$@"; }
48 trouble () { echo >&2 "***TROUBLE***: $*"; trouble=true; }
50 #---------- checks ----------
52 version=$(perl <Cargo.toml -ne '
53 next unless m{^version\s*=\s*\"([0-9.]+)\"\s*$};
54 print "$1\n" or die $!;
59 '') fail "no version?" ;;
62 echo "version $version"
65 diff <(git rev-parse refs/heads/$1) <(git rev-parse HEAD) \
66 || trouble "HEAD not equal to $1"
72 bad=$(git status --porcelain)
73 if [ "x$bad" != x ]; then
74 printf >&2 '%s\n' "$bad"
75 trouble 'tree is dirty'
79 tag_exists=$(git for-each-ref "[r]efs/tags/$tag")
80 if [ "x$tag_exists" != x ]; then trouble "tag $tag already exists"; fi
82 head -1 CHANGELOG.md | grep "^Version $version" \
83 || trouble "CHANGELOG.md not updated"
85 cargo_order='base . cli daemon wasm apitest wdriver jstest'
86 missing=(git ls-files :\*/Cargo.toml :Cargo.toml)
87 for x in $cargo_order; do missing+=(:!$x/Cargo.toml); done
88 missing=$( "${missing[@]}" )
89 if [ "x$missing" != x ]; then trouble "missing cargo package(s) $missing"; fi
91 #---------- end of checks ----------
94 $dryrun fail "trouble! checks failed!"
99 #---------- actually do the work ----------
101 $dryrun git push chiark $branch
102 $dryrun git push origin $branch
104 #---------- non-idempotent things ----------
106 $dryrun make -j12 publish
108 $dryrun git tag -s -u "$keyid" -m "Otter v$version" $tag
109 $dryrun git push chiark $tag
110 $dryrun git push origin $tag
112 #---------- oh woe cargo ----------
114 # https://github.com/rust-lang/cargo/issues/9507
115 wait_for_crates_io () {
118 local url="$cratesio_raw_url/${p:0:2}/${p:2:2}/$p"
119 printf >&2 "waiting for upload of %s to take effect" "$p"
120 while sleep $delay; do
123 curl -sS "$url" | jq '.vers | select(. == "'"$version"'")'
125 if [ "x$got" != x ]; then break; fi
126 delay=$(( $delay * 11 / 10 + 1 ))
131 for cargo_dir in $cargo_order; do
132 $dryrun_no_more_cargo \
133 nailing-cargo --no-nail --linkfarm=git --- \
135 find . ! -type l ! -type d ! -path './target/*' -print0 \
137 cd $cargo_dir; cargo publish $cargo_dryrun
141 sed -n '/^name *=/ { s/^name *= *"\(.*\)" *$/\1/; p; q }' \
142 <$cargo_dir/Cargo.toml
145 wait_for_crates_io "$cargo_package"
147 dryrun_no_more_cargo=$dryrun
151 #---------- finish ----------
156 Successfully released to
164 You need to write release announcements
165 - sgo-software-announce