Skip to content

Commit aca78d9

Browse files
fix(craft): Increment versions in post-release (#1583)
1 parent 9ccf4ec commit aca78d9

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

scripts/bump-version.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ echo $NEW_VERSION
1212

1313
GRADLE_FILEPATH="gradle.properties"
1414

15-
# Increment `buildVersionCode`
16-
VERSION_CODE_PATTERN="buildVersionCode"
17-
VERSION_NUMBER="$( awk "/$VERSION_CODE_PATTERN/" $GRADLE_FILEPATH | grep -o '[0-9]\+' )"
18-
((VERSION_NUMBER++))
19-
sed -i "" -e "s/$VERSION_CODE_PATTERN=.*$/$VERSION_CODE_PATTERN=$VERSION_NUMBER/g" $GRADLE_FILEPATH
20-
2115
# Replace `versionName` with the given version
2216
VERSION_NAME_PATTERN="versionName"
2317
sed -i "" -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$NEW_VERSION/g" $GRADLE_FILEPATH
18+
19+
# Don't bump `buildVersionCode` since it's bumped after doing the release.
20+
# See comments in `post-release.sh`.

scripts/post-release.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,29 @@ NEW_VERSION="${2}"
99

1010
# Add a new unreleased entry in the changelog
1111
sed -i "" 's/# Changelog/# Changelog\n\n## Unreleased/' CHANGELOG.md
12+
13+
# Increment `versionName` and make it a snapshot
14+
# Incrementing the version name before the release (`bump-version.sh`) sets a
15+
# fixed version until the next release it's made. For testing purposes, it's
16+
# interesting to have a different version name that doesn't match the
17+
# name of the version in production.
18+
# Note that the version must end with a number: `1.2.3-alpha` is a semantic
19+
# version but not compatible with this post-release script.
20+
# and `1.2.3-alpha.0` should be used instead.
21+
VERSION_NAME_PATTERN="versionName"
22+
version="$( awk "/$VERSION_NAME_PATTERN/" $GRADLE_FILEPATH | egrep -o '[0-9].*$' )" # from the first digit until the end
23+
version_digit_to_bump="$( awk "/$VERSION_NAME_PATTERN/" $GRADLE_FILEPATH | egrep -o '[0-9]+$')"
24+
((version_digit_to_bump++))
25+
# Using `*` instead of `+` for compatibility. The result is the same,
26+
# since the version to be bumped is extracted using `+`.
27+
new_version="$( echo $version | sed "s/[0-9]*$/$version_digit_to_bump/g" )"
28+
sed -i "" -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$new_version-SNAPSHOT/g" $GRADLE_FILEPATH
29+
30+
# Increment `buildVersionCode`
31+
# After having incremented the version name (see comments above), the new version
32+
# still has the version code of the version in production. This must be
33+
# incremented to align with the new version.
34+
VERSION_CODE_PATTERN="buildVersionCode"
35+
VERSION_NUMBER="$( awk "/$VERSION_CODE_PATTERN/" $GRADLE_FILEPATH | grep -o '[0-9]\+' )"
36+
((VERSION_NUMBER++))
37+
sed -ie "s/$VERSION_CODE_PATTERN=.*$/$VERSION_CODE_PATTERN=$VERSION_NUMBER/g" $GRADLE_FILEPATH

0 commit comments

Comments
 (0)