Skip to content

Commit

Permalink
Bump version locally
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-Fabi committed Jul 10, 2024
1 parent c215b88 commit b528529
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/publishAndroidProd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,4 @@ jobs:
prerelease: true # As the release is not yet available on the Play Store
generate_release_notes: true

- name: Configure git
run: |
git config --global user.name "github-actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Bump version
run: ./gradlew --no-daemon androidApp:bumpVersion

# TODO add notification?
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ see [KMMBridge local dev spm](https://kmmbridge.touchlab.co/docs/spm/IOS_LOCAL_D

Production release can be created with `./gradlew androidApp:release`. This creates a tag in the
form of `android/major.minor.patch` (e.g. android/1.0.0) and triggers the CI build. The version is
taken from the [version.properties](androidApp/version.properties) file.
The app is then automatically deployed to the `internal` track on Google Play.
After the deployment is finished the version will be automatically bumped to the next patch version.
The app must then be promoted to production manually from there after testing. When app is then
taken from the [version.properties](androidApp/version.properties) file. After the tag is pushed
the version will be automatically bumped to the next patch version.
The CI will then then automatically deployed the app to the `internal` track on Google Play.
The app must then be promoted to production manually from there after testing. When the app is then
approved by Google publish the approved changes and remove the pre-release flag on GitHub Releases.
(see [publishAndroidProd.yml](.github/workflows/publishAndroidProd.yml))

Expand Down
20 changes: 5 additions & 15 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ task("release") {
doLast {
val versionParam = findProperty("v")?.toString()

val nextVersion = if (versionParam != null) {
val releaseVersion = if (versionParam != null) {
changeVersion(VersionNumber.fromString(versionParam))
} else {
VersionNumber.fromString(version.toString())
}

val versionTag = "android/$nextVersion"
val versionTag = "android/$releaseVersion"
println("Creating git tag $versionTag")
exec {
commandLine("git", "tag", versionTag)
Expand All @@ -264,19 +264,8 @@ task("release") {
exec {
commandLine("git", "push", "origin", versionTag)
}
}
}

task("bumpVersion") {
doLast {
require(System.getenv("CI")?.lowercase() == true.toString()) {
"Only the CI is allowed to bump the version"
}

val currentVersion = VersionNumber.fromString(version.toString())
val nextVersion = currentVersion.nextPatch()

println("Bumping android version from $currentVersion to $nextVersion")
val nextVersion = releaseVersion.nextPatch()
changeVersion(nextVersion)
}
}
Expand All @@ -287,6 +276,7 @@ private fun changeVersion(toVersion: VersionNumber): VersionNumber {
"The new version $toVersion must be higher than the current version $currentVersion"
}

println("Bumping android version from $currentVersion to $toVersion")
val propertiesFile = getVersionPropertyFile()
versionProperty.setProperty("androidVersion", toVersion.toString())
propertiesFile.outputStream().use { versionProperty.store(it, null) }
Expand All @@ -298,7 +288,7 @@ private fun changeVersion(toVersion: VersionNumber): VersionNumber {
commandLine("git", "commit", "-m", "chore: Bump android version to $toVersion")
}
exec {
commandLine("git", "push", "origin", "HEAD")
commandLine("git", "push")
}

return toVersion
Expand Down

0 comments on commit b528529

Please sign in to comment.