innernet/release.sh
Kevin K 4226278e5a
client, server: add shell completions (#84)
This subcommand takes a shell as an argument and generates shell
completions for that shell to stdout.

example:

```
$ innernet completions bash
  OR
$ innernet-server completions bash
```
2021-05-25 16:10:16 +09:00

46 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
set -e
die () {
echo >&2 "$@"
exit 1
}
for command in help2man cargo-release sed; do
if ! command -v $command &> /dev/null
then
echo "$command binary could not be found"
exit
fi
done
[ "$#" -eq 1 ] || die "usage: ./release.sh [patch|major|minor|rc]"
git diff --quiet || die 'ERROR: git repo is dirty.'
OLD_VERSION="v$(cargo pkgid -p shared | cut -d '#' -f 2)"
cargo release "$1" --no-confirm --exclude "hostsfile" --exclude "publicip"
# re-stage the manpage commit and the cargo-release commit
git reset --soft @~1
cargo build
for binary in "innernet" "innernet-server"; do
for shell in {fish,zsh,bash,powershell,elvish}; do
"target/debug/$binary" completions $shell > doc/$binary.completions.$shell
git diff --quiet -- doc/$binary.completions.$shell || die "CLI and Completions out of sync for $shell"
done
help2man --no-discard-stderr -s8 "target/debug/$binary" -N > "doc/$binary.8"
gzip -fk "doc/$binary.8"
done
VERSION="v$(cargo pkgid -p shared | cut -d '#' -f 2)"
perl -pi -e "s/$OLD_VERSION/$VERSION/g" README.md
git add doc
git add README.md
git commit -m "meta: release $VERSION"
git tag -f -a "$VERSION" -m "release $VERSION"