Skip to content

Commit

Permalink
fix(craft): Increment versions in post-release (#1583)
Browse files Browse the repository at this point in the history
  • Loading branch information
iker-barriocanal authored Jul 3, 2021
1 parent 9ccf4ec commit aca78d9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
9 changes: 3 additions & 6 deletions scripts/bump-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ echo $NEW_VERSION

GRADLE_FILEPATH="gradle.properties"

# Increment `buildVersionCode`
VERSION_CODE_PATTERN="buildVersionCode"
VERSION_NUMBER="$( awk "/$VERSION_CODE_PATTERN/" $GRADLE_FILEPATH | grep -o '[0-9]\+' )"
((VERSION_NUMBER++))
sed -i "" -e "s/$VERSION_CODE_PATTERN=.*$/$VERSION_CODE_PATTERN=$VERSION_NUMBER/g" $GRADLE_FILEPATH

# Replace `versionName` with the given version
VERSION_NAME_PATTERN="versionName"
sed -i "" -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$NEW_VERSION/g" $GRADLE_FILEPATH

# Don't bump `buildVersionCode` since it's bumped after doing the release.
# See comments in `post-release.sh`.
26 changes: 26 additions & 0 deletions scripts/post-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,29 @@ NEW_VERSION="${2}"

# Add a new unreleased entry in the changelog
sed -i "" 's/# Changelog/# Changelog\n\n## Unreleased/' CHANGELOG.md

# Increment `versionName` and make it a snapshot
# Incrementing the version name before the release (`bump-version.sh`) sets a
# fixed version until the next release it's made. For testing purposes, it's
# interesting to have a different version name that doesn't match the
# name of the version in production.
# Note that the version must end with a number: `1.2.3-alpha` is a semantic
# version but not compatible with this post-release script.
# and `1.2.3-alpha.0` should be used instead.
VERSION_NAME_PATTERN="versionName"
version="$( awk "/$VERSION_NAME_PATTERN/" $GRADLE_FILEPATH | egrep -o '[0-9].*$' )" # from the first digit until the end
version_digit_to_bump="$( awk "/$VERSION_NAME_PATTERN/" $GRADLE_FILEPATH | egrep -o '[0-9]+$')"
((version_digit_to_bump++))
# Using `*` instead of `+` for compatibility. The result is the same,
# since the version to be bumped is extracted using `+`.
new_version="$( echo $version | sed "s/[0-9]*$/$version_digit_to_bump/g" )"
sed -i "" -e "s/$VERSION_NAME_PATTERN=.*$/$VERSION_NAME_PATTERN=$new_version-SNAPSHOT/g" $GRADLE_FILEPATH

# Increment `buildVersionCode`
# After having incremented the version name (see comments above), the new version
# still has the version code of the version in production. This must be
# incremented to align with the new version.
VERSION_CODE_PATTERN="buildVersionCode"
VERSION_NUMBER="$( awk "/$VERSION_CODE_PATTERN/" $GRADLE_FILEPATH | grep -o '[0-9]\+' )"
((VERSION_NUMBER++))
sed -ie "s/$VERSION_CODE_PATTERN=.*$/$VERSION_CODE_PATTERN=$VERSION_NUMBER/g" $GRADLE_FILEPATH

0 comments on commit aca78d9

Please sign in to comment.