Skip to content

Commit

Permalink
Use build number in android + desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-powell authored and github-actions[bot] committed Jan 11, 2024
1 parent a57e91a commit 00add19
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
gradle-home-cache-cleanup: true

- name: Build with Gradle
run: ./gradlew composeApp:assembleDebug
run: ./gradlew composeApp:assembleDebug -Pbuild-numeber=${{ needs.build-number.outputs.build-number }}

build-release:
runs-on: ubuntu-latest
Expand All @@ -51,7 +51,7 @@ jobs:
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew composeApp:assembleRelease
run: ./gradlew composeApp:assembleRelease -Pbuild-numeber=${{ needs.build-number.outputs.build-number }}

test:
runs-on: ubuntu-latest
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build-number.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ on:
default: ${{ github.token }}
type: string

#concurrency:
# group: ${{ github.ref }}
# cancel-in-progress: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
build_number: ${{ steps.build-number.outputs.BUILD_NUMBER }}
build-number: ${{ steps.build-number.outputs.BUILD_NUMBER }}
steps:
- uses: actions/checkout@v4
with:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- ci-version-code # TODO: this is a temporary branch for testing (REMOVE)
pull_request:

concurrency:
Expand Down
10 changes: 9 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import org.jetbrains.compose.ComposeExtension
// Manifest version information!
val versionMajor = 1
val versionMinor = 0
val versionPatch = 0
val versionBuild = providers.gradleProperty("build-number").orElse("0").map { it.toInt() }
val versionName = "$versionMajor.$versionMinor.$versionPatch"

group = "com.greenmiststudios"
version = "1.0-SNAPSHOT"
Expand All @@ -24,6 +29,9 @@ plugins {
}

allprojects {
ext.set("version", versionName)
ext.set("versionBuild", versionBuild)

extensions.findByType<com.diffplug.gradle.spotless.SpotlessExtension>()?.apply { // if you are using build.gradle.kts, instead of 'spotless {' use:
kotlin {
// by default the target is every '.kt' and '.kts` file in the java sourcesets
Expand Down
8 changes: 5 additions & 3 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ plugins {
alias(libs.plugins.spotless)
}

val projectVersion = project.ext.get("version")?.toString()

kotlin {
js(IR) {
browser {
Expand Down Expand Up @@ -82,8 +84,8 @@ android {
applicationId = "com.greenmiststudios.tidy"
minSdk = libs.versions.android.minSdk.get().toInt()
targetSdk = libs.versions.android.targetSdk.get().toInt()
versionCode = project.properties["tidy.version_code"]?.toString()?.toInt() ?: 1
versionName = project.properties["tidy.version_name"]?.toString()
versionCode = project.ext.get("versionBuild")?.toString()?.toInt() ?: 0
versionName = projectVersion
}
packaging {
resources {
Expand Down Expand Up @@ -114,7 +116,7 @@ compose.desktop {
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "com.greenmiststudios.tidy"
packageVersion = project.properties["tidy.version_name"]?.toString()
packageVersion = projectVersion
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions scripts/build-number.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
set -x

TAGS=$(git show-ref --tags)

function getBuildNumberTag {
Expand Down Expand Up @@ -42,4 +40,5 @@ else
echo "Skipping tag creation."
fi

echo "BUILD_NUMBER=$CURRENT_BUILD_NUMBER" >> "$GITHUB_ENV"
echo "BUILD_NUMBER=$CURRENT_BUILD_NUMBER" >> "$GITHUB_ENV"
echo "BUILD_NUMBER=$CURRENT_BUILD_NUMBER" >> "$GITHUB_OUTPUT"

0 comments on commit 00add19

Please sign in to comment.