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=x ; cargo_dryrun='' ; ;;
19 2.--dry-run) dryrun=dryrun; cargo_dryrun='--dry-run'; ;;
20 *) fail "bad usage" ;;
23 keyid=0x559AE46C2D6B6D3265E7CBA1E3E3392348B50D39
27 dryrun () { echo "WOULD $*"; }
28 x () { echo >&2 "+ $*"; "$@"; }
31 trouble () { echo >&2 "***TROUBLE***: $*"; trouble=true; }
33 #---------- checks ----------
35 version=$(perl <Cargo.toml -ne '
36 next unless m{^version\s*=\s*\"([0-9.]+)\"\s*$};
37 print "$1\n" or die $!;
42 '') fail "no version?" ;;
45 echo "version $version"
48 diff <(git rev-parse refs/heads/$1) <(git rev-parse HEAD) \
49 || trouble "HEAD not equal to $1"
55 bad=$(git status --porcelain)
56 if [ "x$bad" != x ]; then
57 printf >&2 '%s\n' "$bad"
58 trouble 'tree is dirty'
62 tag_exists=$(git for-each-ref "[r]efs/tags/$tag")
63 if [ "x$tag_exists" != x ]; then trouble "tag $tag already exists"; fi
66 cargo_order='base . daemon wasm apitest wdriver'
67 missing=(git ls-files :\*/Cargo.toml :Cargo.toml)
68 for x in $cargo_order; do missing+=(:!$x/Cargo.toml); done
69 missing=$( "${missing[@]}" )
70 if [ "x$missing" != x ]; then trouble "missing cargo package(s) $missing"; fi
72 #---------- end of checks ----------
75 $dryrun fail "trouble! checks failed!"
80 #---------- actually do the work ----------
82 $dryrun git push chiark $branch
83 $dryrun git push origin $branch
85 #---------- non-idempotent things ----------
87 $dryrun make -j12 publish
89 $dryrun git tag -s -u "$keyid" -m "Otter v$version" $tag
90 $dryrun git push chiark $tag
91 $dryrun git push origin $tag
94 for cargo_dir in $cargo_order; do
95 $dryrun_no_more_cargo \
96 nailing-cargo --no-nail --linkfarm=git --- \
97 sh -xec "cd $cargo_dir; cargo publish $cargo_dryrun"
98 dryrun_no_more_cargo=$dryrun
101 #---------- finish ----------
106 Successfully released to
114 You need to write release announcements
115 - sgo-software-announce