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
65 head -1 CHANGELOG.md | grep "^Version $version" \
66 || trouble "CHANGELOG.md not updated"
68 cargo_order='base . daemon wasm apitest wdriver'
69 missing=(git ls-files :\*/Cargo.toml :Cargo.toml)
70 for x in $cargo_order; do missing+=(:!$x/Cargo.toml); done
71 missing=$( "${missing[@]}" )
72 if [ "x$missing" != x ]; then trouble "missing cargo package(s) $missing"; fi
74 #---------- end of checks ----------
77 $dryrun fail "trouble! checks failed!"
82 #---------- actually do the work ----------
84 $dryrun git push chiark $branch
85 $dryrun git push origin $branch
87 #---------- non-idempotent things ----------
89 $dryrun make -j12 publish
91 $dryrun git tag -s -u "$keyid" -m "Otter v$version" $tag
92 $dryrun git push chiark $tag
93 $dryrun git push origin $tag
96 for cargo_dir in $cargo_order; do
97 $dryrun_no_more_cargo \
98 nailing-cargo --no-nail --linkfarm=git --- \
100 find . ! -type l ! -type d ! -path './target/*' -print0 \
102 cd $cargo_dir; cargo publish $cargo_dryrun
104 dryrun_no_more_cargo=$dryrun
108 #---------- finish ----------
113 Successfully released to
121 You need to write release announcements
122 - sgo-software-announce