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

Use number of commits on branch as the version code #210

Merged
merged 3 commits into from May 25, 2018

Conversation

oliverlockwood
Copy link
Member

@oliverlockwood oliverlockwood commented May 25, 2018

Connects to #179.

The Play store APIs only accept an APK submission if the versionCode (an integer) has not already been used. You can see an example failure here:

:cyclestreets.app:publishApkRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':cyclestreets.app:publishApkRelease'.
> com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
 {
   "code" : 403,
   "errors" : [ {
     "domain" : "androidpublisher",
     "message" : "APK specifies a version code that has already been used.",
     "reason" : "apkUpgradeVersionConflict"
   } ],
   "message" : "APK specifies a version code that has already been used."
 }

Therefore, versionCode has to be monotonically increasing.

The most logical way I could come up with for deriving a monotonically increasing number for our CI builds was to use the number of commits. On the master branch (which is the only branch that will attempt to push to the Play store anyway), this number should never go down, assuming that we don't intend to rewrite history.

@oliverlockwood oliverlockwood merged commit b37cc0c into master May 25, 2018
@oliverlockwood oliverlockwood deleted the fix-beta-publishing branch May 25, 2018 09:18
@mvl22
Copy link
Member

mvl22 commented May 26, 2018

Great idea - thanks.

@oliverlockwood
Copy link
Member Author

👍

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.

None yet

2 participants