@@ -9,3 +9,29 @@ NEW_VERSION="${2}"
99
1010# Add a new unreleased entry in the changelog
1111sed -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