4 # ./make-release --dry-run|--real <branch>
6 # ./make-release --dry-run main
8 #---------- argument parsing and options ----------
12 fail () { echo >&2 "${0##*/}: error: $*"; exit 12; }
14 dryrun=x-dry-run-unset
15 cargo_dryrun=--not-a-cargo-option-please-crash
18 2.--real) dryrun='' ; cargo_dryrun='' ; ;;
19 2.--dry-run) dryrun=dryrun; cargo_dryrun='--dry-run'; ;;
20 *) fail "bad usage" ;;
23 keyid=0x559AE46C2D6B6D3265E7CBA1E3E3392348B50D39
27 dryrun () { echo "WOULD $*"; }
30 trouble () { echo >&2 "***TROUBLE***: $*"; trouble=true; }
32 #---------- checks ----------
34 version=$(perl <Cargo.toml -ne '
35 next unless m{^version\s*=\s*\"([0-9.]+)\"\s*$};
36 print "$1\n" or die $!;
41 '') fail "no version?" ;;
44 echo "version $version"
47 diff <(git rev-parse refs/heads/$1) <(git rev-parse HEAD) \
48 || trouble "HEAD not equal to $1"
54 bad=$(git status --porcelain)
55 if [ "x$bad" != x ]; then
56 printf >&2 '%s\n' "$bad"
57 trouble 'tree is dirty'
61 tag_exists=$(git for-each-ref "[r]efs/tags/$tag")
62 if [ "x$tag_exists" != x ]; then trouble "tag $tag already exists"; fi
65 cargo_order='base . daemon wasm apitest wdriver'
66 missing=(git ls-files :\*/Cargo.toml :Cargo.toml)
67 for x in $cargo_order; do missing+=(:!$x/Cargo.toml); done
68 missing=$( "${missing[@]}" )
69 if [ "x$missing" != x ]; then trouble "missing cargo package(s) $missing"; fi
71 #---------- end of checks ----------
74 $dryrun fail "trouble! checks failed!"
79 #---------- actually do the work ----------
81 $dryrun git push chiark $branch
82 $dryrun git push origin $branch
84 #---------- non-idempotent things ----------
86 $dryrun make -j12 publish
88 $dryrun git tag -s -u "$keyid" -m "Otter v$version"
89 $dryrun git push chiark $tag
90 $dryrun git push origin $tag
93 for cargo_dir in $cargo_order; do
94 $dryrun_no_more_cargo \
95 nailing-cargo --no-nail --linkfarm=git --- \
96 sh -xec "cd $cargo_dir; cargo publish $cargo_dryrun"
97 dryrun_no_more_cargo=$dryrun
100 #---------- finish ----------
103 Successfully released to
108 You need to write release announcements
109 - sgo-software-announce