Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic version bumping #96

Merged
merged 9 commits into from
Sep 19, 2022

Conversation

hhio618
Copy link
Contributor

@hhio618 hhio618 commented May 20, 2022

Description

closes #94

Tasks

  1. Ensure clean repo and bumping a release (using either type or version parameters) and commit the changes and prepare for the next development cycle:
$ ./gradlew releasePrepare [-PbumpType=(major|minor|patch)] [-PbumpVersion=x.y.z]
  1. Push the changes to git using the Gradle-git plugin:
$ ./gradlew releasePerform

@hhio618 hhio618 requested a review from a team as a code owner May 20, 2022 19:43
build.gradle Outdated Show resolved Hide resolved
Copy link
Member

@nya-elimu nya-elimu left a comment

Choose a reason for hiding this comment

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

@hhio618 Thank you, this is really cool to see!

I tried running ./gradlew releasePrepare, and got "unspecified" as the new versionName:

Bumping versionName from 1.1.4 to unspecified
Bumping versionCode from 1001004 to 1001005

Screen Shot 2022-05-21 at 7 02 41 PM

Would it be possible to set the versionName as well?

@hhio618 hhio618 force-pushed the hhio618/dw-223/vitabu-automate-bumping branch from 3374122 to 086d404 Compare May 21, 2022 13:45
@hhio618
Copy link
Contributor Author

hhio618 commented May 21, 2022

Thanks, @nya-elimuai. you need to specify either bumpType or bumpVersion parameters to get this to work:
Example:

./gradlew releasePrepare -PbumpType=patch # will increase the patch number, choices=major,minor,patch
./gradlew releasePrepare -PbumpVersion=x.y.z # bump to a specific version.

I added an exception to prompt for either of these parameters.

app/build.gradle Outdated
newVersionName = project.properties["version"]
}else {
print project.properties.containsKey("bumpVersion")
if (project.properties.containsKey("bumpVersion")){
Copy link
Member

Choose a reason for hiding this comment

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

Add missing whitespace: ) {

@nya-elimu
Copy link
Member

#96 (comment)

@hhio618 This is really cool! Tested with ./gradlew releasePrepare -PbumpType=patch:

Screen Shot 2022-05-27 at 8 08 06 PM

Screen Shot 2022-05-27 at 8 08 14 PM

Copy link
Member

@nya-elimu nya-elimu left a comment

Choose a reason for hiding this comment

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

@hhio618 This is really great! Amazing work 👏🏽

I only have one final adjustment, when running ./gradlew releasePrepare -PbumpType=patch: Instead of bumping the version before the release, bump it after the release. That way it would work the same as with the webapp release versioning.

Example: If the version looks like this before the release:

versionCode 1001005
versionName '1.1.5-SNAPSHOT'

change it to

versionCode 1001005
versionName '1.1.5'

Then release (commit to Git).

And then (after the release), bump the version for the next iteration:

versionCode 1001006
versionName '1.1.6-SNAPSHOT'

app/build.gradle Outdated
if (project.properties.containsKey("version")){
newVersionName = project.properties["version"]
}else {
print project.properties.containsKey("bumpVersion")
Copy link
Member

Choose a reason for hiding this comment

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

Include a text that explains the printout (to know where in the code the log output comes from)

app/build.gradle Outdated
print project.properties.containsKey("bumpVersion")
if (project.properties.containsKey("bumpVersion")){
newVersionName = project.properties["bumpVersion"]
}else if (project.properties.containsKey("bumpType")) {
Copy link
Member

Choose a reason for hiding this comment

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

Add missing whitespace: } else

app/build.gradle Outdated
@@ -103,6 +104,8 @@ task releasePrepare(dependsOn: releaseClean) {
break
}
newVersionName = "$major.$minor.$patch"
}else{
Copy link
Member

Choose a reason for hiding this comment

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

Add missing whitespace: } else {

@hhio618 hhio618 force-pushed the hhio618/dw-223/vitabu-automate-bumping branch from 32bdd85 to baceb0e Compare May 27, 2022 17:55
@hhio618
Copy link
Contributor Author

hhio618 commented May 27, 2022

@nya-elimuai Thanks for the review! I made the changes you mentioned.

@hhio618 hhio618 requested a review from nya-elimu May 28, 2022 13:25
Copy link
Member

@nya-elimu nya-elimu left a comment

Choose a reason for hiding this comment

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

Thank you, @hhio618!

Now ./gradlew releasePrepare -PbumpType=patch worked perfectly:

Bumping versionName from 1.1.4 to 1.1.5
Bumping versionCode from 1001004 to 1001005

c028067
b75c052

However, ./gradlew releasePerform failed:

./gradlew releasePerform                 

Task 'releasePerform' not found in root project 'Vitabu'.

Am I using ./gradlew releasePerform correctly?

@hhio618 hhio618 force-pushed the hhio618/dw-223/vitabu-automate-bumping branch 3 times, most recently from 32f7881 to 7d42b5e Compare June 2, 2022 16:08
@hhio618 hhio618 force-pushed the hhio618/dw-223/vitabu-automate-bumping branch from 7d42b5e to 801a406 Compare June 2, 2022 16:16
@hhio618
Copy link
Contributor Author

hhio618 commented Jun 2, 2022

@nya-elimuai Fixed, I also updated the releaseClean task to rollback/clean git commit history before calling the releasePrepare task.

app/build.gradle Outdated
}
}
}
task releaseClean(dependsOn: ensureCleanRepo) {
doLast {
def Clean = true
Copy link
Member

Choose a reason for hiding this comment

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

Make Clean lower-case: clean

app/build.gradle Outdated
while (headCommitMessage.contains("[gradle-release-task]")) {
Clean = false
println "Found git commit: $headCommitMessage"
if (headCommitMessage.indexOf("vitabu-") > -1) {
Copy link
Member

@nya-elimu nya-elimu Jun 3, 2022

Choose a reason for hiding this comment

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

To make the solution scalable to other Android apps (with different names, can you change "vitabu-" into a variable? For example by using the applicationId variable instead?

Would require adjusting the string used in grgit.commit(): "prepare release ${applicationId}-"

app/build.gradle Outdated
Clean = false
println "Found git commit: $headCommitMessage"
if (headCommitMessage.indexOf("vitabu-") > -1) {
def tagName = headCommitMessage.split("vitabu-")[1]
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here as above.

app/build.gradle Outdated
headCommitMessage = grgit.head().shortMessage

}
if (Clean){
Copy link
Member

Choose a reason for hiding this comment

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

Change to if (clean) {

Copy link
Member

@nya-elimu nya-elimu left a comment

Choose a reason for hiding this comment

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

Looks great! Only added a suggestion to use the applicationId variable.

@hhio618 hhio618 force-pushed the hhio618/dw-223/vitabu-automate-bumping branch from 9656e87 to 6bfd05c Compare June 4, 2022 07:13
@hhio618 hhio618 requested a review from nya-elimu June 4, 2022 07:52
Copy link
Member

@nya-elimu nya-elimu left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automate bumping of version in app/build.gradle
2 participants