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
20 changes: 15 additions & 5 deletions tools/bump-version
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
set -eu

usage () {
cat <<EOF >&2
Expand All @@ -12,13 +12,23 @@ EOF

shift && usage;

major_version=30
minor_version=0
pub_version_regexp="${major_version}\.${minor_version}\.(\d+)\+\1"

date="$(date --iso)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script needs to ensure GNU coreutils are used on macOS (ensure-coreutils.sh).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. That's an existing issue, right? I'll make a separate follow-up PR for it.


old_version_int="$(perl -lne '
print $1 if (/^version: 0\.0\.(\d+)\+\1$/);
print $1 if (/^version: '"${pub_version_regexp}"'$/);
' pubspec.yaml)"
if [ -z "${old_version_int}" ]; then
echo >&2 "error: failed to parse current version in pubspec.yaml"
exit 1
fi

version_int=$(( old_version_int + 1 ))
version_name="0.0.${version_int}"
version_name="${major_version}.${minor_version}.${version_int}"
pub_version="${version_name}+${version_int}"
tag_name=v"${version_name}"

had_uncommitted=
Expand All @@ -27,8 +37,8 @@ if ! git diff-index --quiet HEAD; then
fi

perl -i -0pe '
s<^version: \K0\.0\.(\d+)\+\1$>
<0.0.'"${version_int}"'+'"${version_int}"'>m;
s<^version: \K'"${pub_version_regexp}"'$>
<'"${pub_version}"'>m;
' pubspec.yaml

perl -i -0pe '
Expand Down