4 # ./make-release --dry-run|--real <branch>
6 # ./make-release --dry-run main
8 #---------- argument parsing and options ----------
13 fail () { echo >&2 "${0##*/}: error: $*"; exit 12; }
15 dryrun=x-dry-run-unset
16 cargo_dryrun=--not-a-cargo-option-please-crash
19 2.--real) dryrun=x ; cargo_dryrun='' ; ;;
20 2.--dry-run) dryrun=dryrun; cargo_dryrun='--dry-run'; ;;
21 *) fail "bad usage" ;;
24 keyid=0x559AE46C2D6B6D3265E7CBA1E3E3392348B50D39
28 dryrun () { echo "WOULD $*"; }
29 x () { echo >&2 "+ $*"; "$@"; }
32 trouble () { echo >&2 "***TROUBLE***: $*"; trouble=true; }
34 #---------- checks ----------
36 version=$(perl <Cargo.toml -ne '
37 next unless m{^version\s*=\s*\"([0-9.]+)\"\s*$};
38 print "$1\n" or die $!;
43 '') fail "no version?" ;;
46 echo "version $version"
49 diff <(git rev-parse refs/heads/$1) <(git rev-parse HEAD) \
50 || trouble "HEAD not equal to $1"
56 bad=$(git status --porcelain)
57 if [ "x$bad" != x ]; then
58 printf >&2 '%s\n' "$bad"
59 trouble 'tree is dirty'
63 tag_exists=$(git for-each-ref "[r]efs/tags/$tag")
64 if [ "x$tag_exists" != x ]; then trouble "tag $tag already exists"; fi
66 head -1 CHANGELOG.md | grep "^Version $version" \
67 || trouble "CHANGELOG.md not updated"
69 cargo_order='base . cli daemon wasm apitest wdriver'
70 missing=(git ls-files :\*/Cargo.toml :Cargo.toml)
71 for x in $cargo_order; do missing+=(:!$x/Cargo.toml); done
72 missing=$( "${missing[@]}" )
73 if [ "x$missing" != x ]; then trouble "missing cargo package(s) $missing"; fi
75 #---------- end of checks ----------
78 $dryrun fail "trouble! checks failed!"
83 #---------- actually do the work ----------
85 $dryrun git push chiark $branch
86 $dryrun git push origin $branch
88 #---------- non-idempotent things ----------
90 $dryrun make -j12 publish
92 $dryrun git tag -s -u "$keyid" -m "Otter v$version" $tag
93 $dryrun git push chiark $tag
94 $dryrun git push origin $tag
97 for cargo_dir in $cargo_order; do
98 $dryrun_no_more_cargo \
99 nailing-cargo --no-nail --linkfarm=git --- \
101 find . ! -type l ! -type d ! -path './target/*' -print0 \
103 cd $cargo_dir; cargo publish $cargo_dryrun
105 dryrun_no_more_cargo=$dryrun
109 #---------- finish ----------
114 Successfully released to
122 You need to write release announcements
123 - sgo-software-announce