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
16 # - make-release --dry-run
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 support . 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_VERSION=$version publish
107 $dryrun make -j12 PUBLISH_VERSION=$version publish-make-current
109 $dryrun git tag -s -u "$keyid" -m "Otter v$version" $tag
110 $dryrun git push chiark $tag
111 $dryrun git push origin $tag
113 #---------- oh woe cargo ----------
115 # https://github.com/rust-lang/cargo/issues/9507
116 wait_for_crates_io () {
119 local url="$cratesio_raw_url/${p:0:2}/${p:2:2}/$p"
120 printf >&2 "waiting for upload of %s to take effect" "$p"
121 while sleep $delay; do
124 curl -sS "$url" | jq '.vers | select(. == "'"$version"'")'
126 if [ "x$got" != x ]; then break; fi
127 delay=$(( $delay * 11 / 10 + 1 ))
132 for cargo_dir in $cargo_order; do
133 $dryrun_no_more_cargo \
134 nailing-cargo --no-nail --preclean-build=src --git --- \
136 cd $cargo_dir; cargo publish $cargo_dryrun
140 sed -n '/^name *=/ { s/^name *= *"\(.*\)" *$/\1/; p; q }' \
141 <$cargo_dir/Cargo.toml
144 wait_for_crates_io "$cargo_package"
146 dryrun_no_more_cargo=$dryrun
150 #---------- finish ----------
155 Successfully released to
163 You need to write release announcements
164 - sgo-software-announce