-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
release.sh
executable file
·34 lines (28 loc) · 877 Bytes
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")"
function get_version() {
cargo metadata --format-version=1 --no-deps --locked \
| jq -r '.packages[].version'
}
if [ -n "$(git status --untracked-files=no --porcelain)" ]; then
echo "Your working directory is not clean"
exit 1
fi
echo "Current Version:" $(get_version)
printf "New Version: "
read version0
version="$(echo "$version0" | tr -d '[:blank:]')"
sed -E -e '/^\[package\]$/,/^\[/ {/version =/ {s/"[^"]*"/"'"$version"'"/; :a;n;ba}}' \
-i Cargo.toml
if [ "$(get_version)" != "$version" ]; then
echo "Failed to set version"
exit 1
fi
cargo update -p cargo-doc2readme
git commit Cargo.toml Cargo.lock -m "Release cargo-doc2readme $version"
git push
git tag -s -a -m "Version $version" "$version"
git push --tags
cargo publish --locked
xdg-open "https://github.com/msrd0/cargo-doc2readme/releases/new"