4 # ./make-release --dry-run|--real <branch>
6 # ./make-release --dry-run main
9 # Overall release steps:
11 # - update dependencies (cargo update, cargo upgrades)
14 # - ensure pretest == tested == main
15 # - make deploy and test that chiark still works
17 # - release announcement to mailing list
20 #---------- argument parsing and options ----------
25 fail () { echo >&2 "${0##*/}: error: $*"; exit 12; }
27 dryrun=x-dry-run-unset
28 cargo_dryrun=--not-a-cargo-option-please-crash
31 2.--real) dryrun=x ; cargo_dryrun='' ; ;;
32 2.--dry-run) dryrun=dryrun; cargo_dryrun='--dry-run'; ;;
33 *) fail "bad usage" ;;
36 keyid=0x559AE46C2D6B6D3265E7CBA1E3E3392348B50D39
39 https://raw.githubusercontent.com/rust-lang/crates.io-index/master
43 dryrun () { echo "WOULD $*"; }
44 x () { echo >&2 "+ $*"; "$@"; }
47 trouble () { echo >&2 "***TROUBLE***: $*"; trouble=true; }
49 #---------- checks ----------
51 version=$(perl <Cargo.toml -ne '
52 next unless m{^version\s*=\s*\"([0-9.]+)\"\s*$};
53 print "$1\n" or die $!;
58 '') fail "no version?" ;;
61 echo "version $version"
64 diff <(git rev-parse refs/heads/$1) <(git rev-parse HEAD) \
65 || trouble "HEAD not equal to $1"
71 bad=$(git status --porcelain)
72 if [ "x$bad" != x ]; then
73 printf >&2 '%s\n' "$bad"
74 trouble 'tree is dirty'
78 tag_exists=$(git for-each-ref "[r]efs/tags/$tag")
79 if [ "x$tag_exists" != x ]; then trouble "tag $tag already exists"; fi
81 head -1 CHANGELOG.md | grep "^Version $version" \
82 || trouble "CHANGELOG.md not updated"
84 cargo_order='base support . cli daemon wasm apitest wdriver jstest'
85 missing=(git ls-files :\*/Cargo.toml :Cargo.toml)
86 for x in $cargo_order; do missing+=(:!$x/Cargo.toml); done
87 missing=$( "${missing[@]}" )
88 if [ "x$missing" != x ]; then trouble "missing cargo package(s) $missing"; fi
90 #---------- end of checks ----------
93 $dryrun fail "trouble! checks failed!"
98 #---------- actually do the work ----------
100 $dryrun git push chiark $branch
101 $dryrun git push origin $branch
103 #---------- non-idempotent things ----------
105 $dryrun make -j12 PUBLISH_VERSION=$version publish
106 $dryrun make -j12 PUBLISH_VERSION=$version publish-make-current
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 --preclean-build=src --git --- \
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