Skip to content

Commit

Permalink
Added release script.
Browse files Browse the repository at this point in the history
  • Loading branch information
orium committed Mar 2, 2019
1 parent 67380ec commit 032217c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tools/codecov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ kcov --verify target/cov \
target/debug/$build $@ 2>&1 >/dev/null

# TODO The symbolic link that kcov generates is broken, so we have to do this workaround.
report_dir=$(readlink target/cov/$build | sed 's,/*$,,' | rev | cut -d/ -f1 | rev)
report_dir=$(readlink target/cov/$build | sed 's,/*$,,' | tac -s'/' | head -1)

echo "You can find the test coverage results at file://$(pwd)/target/cov/$report_dir/index.html"
79 changes: 79 additions & 0 deletions tools/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

set -e

cd $(dirname "$0")
cd "$(git rev-parse --show-toplevel)"

source "tools/utils.sh"

function set_version {
local version=$1

sed -i "0,/version = .*$/s//version = \"$version\"/" Cargo.toml
}

if [ $(git symbolic-ref --short HEAD) != master ]; then
echo "Not in master branch." >&2
exit 1
fi

if [ $(git status --porcelain | wc -l) -ne 0 ]; then
echo "Working directory is not clean." >&2
exit 1
fi

echo "Current version is $(project_version)."

echo -n "Which version do you want to release? "
read release_version

if ! grep "^## " release-notes.md | head -1 | grep --silent "^## $release_version$"; then
echo "You forgot to update the release notes." >&2
exit 1
fi

echo -n "Which will be the next version? "
read next_version

if ! echo "$next_version" | grep --silent -- "-pre$"; then
echo 'Next version must end in `-pre`.' >&2
fi

echo
echo "Current version: $(project_version)"
echo "Release version: $release_version"
echo "Next version: $next_version"
echo
echo -n 'Does this look right [yes/no]? '

read answer

if [ "$answer" != "yes" ]; then
exit 0
fi

echo "Running tests..."

if ! ./tools/check.sh 2>&1 > /dev/null; then
echo "It failed :(" >&2
exit 0
fi

set_version "$release_version"

git commit -am "Release v${release_version}."
git tag --sign -a "v${release_version}" -m "$(project_name) version ${release_version}."

set_version "$next_version"

git commit -am "Bump to version $next_version."

echo "Check if everything is alright. If so do:"
echo
echo " git checkout \"v${release_version}\" && cargo publish && git checkout master && git push --follow-tags"
echo
4 changes: 3 additions & 1 deletion tools/update-readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ set -e
cd $(dirname "$0")
cd "$(git rev-parse --show-toplevel)"

source "tools/utils.sh"

function new_readme {
filename=$(mktemp)

Expand All @@ -18,7 +20,7 @@ function new_readme {

grep --no-filename '//!' src/lib.rs \
| sed 's,^//!\( \|\),,' \
| sed 's,\](\./\([^)]*\.html\)),](https://docs.rs/rpds/latest/rpds/\1),' \
| sed "s,\](\./\([^)]*\.html\)),](https://docs.rs/$(project_name)/latest/$(project_name)/\1)," \
| grep -v DROP_LINE_IN_README >> "$filename"

echo "$filename"
Expand Down
10 changes: 9 additions & 1 deletion tools/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,13 @@ function unit_tests_build {
# TODO Maybe in the future there will be a better way. See https://github.com/rust-lang/cargo/issues/1924.
cargo test --no-run --message-format=json 2>/dev/null \
| jq -r "select(.profile.test == true) | .filenames[]" \
| rev | cut -d'/' -f 1 | rev
| tac -s'/' | head -1
}

function project_name {
cargo pkgid | tac -s'/' | head -1 | cut -d'#' -f1
}

function project_version {
cargo pkgid | tac -s'/' | head -1 | cut -d'#' -f2
}

0 comments on commit 032217c

Please sign in to comment.