Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -eo pipefail
shopt -s extglob

version=$1
branch_name=$(git rev-parse --abbrev-ref HEAD)

awk-in-place () {
local tmpfile=$(mktemp)
Expand Down Expand Up @@ -35,7 +34,17 @@ crate-names () {
cargo metadata --format-version 1 --no-deps | jq -r '.packages[].name'
}

branch-name () {
git rev-parse --abbrev-ref HEAD
}

auto-pr () {
local branch_name="$(branch-name)"
if [[ "$(branch-name)" = main ]] ; then
echo "Cannot auto-pr on main branch." >&2
return 1
fi

pr_url=$((gh pr view --json url,closed 2>/dev/null || true) \
| jq -r 'select(.closed | not) | .url')

Expand Down Expand Up @@ -90,7 +99,7 @@ command -v parse-changelog &>/dev/null || {
exit 1
}

if [[ "$branch_name" = main ]] ; then
if [[ "$(branch-name)" = main ]] ; then
git switch -c "release-$version"
fi

Expand All @@ -106,6 +115,7 @@ awk-in-place Cargo.toml '
{ print }'

# Fix docs.rs links in README, if present
echo 'Updating links in README.md'
for name in $(crate-names) ; do
awk-in-place README.md '{
sub(/https:\/\/docs\.rs\/'"$name"'\/[0-9]+.[0-9]+.[0-9]+\//, \
Expand All @@ -118,7 +128,9 @@ cargo check --quiet

# Do semver checks only if there is a version on crates.io to compare to.
# FIXME: can’t tell if crates.io search failed for another reason.
if (cd / && cargo info "$(crate-names | head -1)" &>/dev/null) ; then
main_crate_name=$(crate-names | head -1)
if (cd / && cargo info "$main_crate_name" &>/dev/null) ; then
echo 'Doing semantic versioning checks'
cargo semver-checks || { echo ; confirm 'Release anyway?' ; }
fi

Expand Down
Loading