From abe75d0ec5757e982652bab43490853478bd420a Mon Sep 17 00:00:00 2001 From: Geoff Powell Date: Thu, 11 Jan 2024 12:34:09 -0500 Subject: [PATCH] Use build number in android + desktop (#68) --- .github/workflows/android.yml | 4 ++-- .github/workflows/build-number.yml | 8 ++++---- .github/workflows/ios.yml | 1 - build.gradle.kts | 10 +++++++++- composeApp/build.gradle.kts | 8 +++++--- scripts/build-number.sh | 5 ++--- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index eeb1de7..3fc8f95 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -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 @@ -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 diff --git a/.github/workflows/build-number.yml b/.github/workflows/build-number.yml index 1023b27..022e0c2 100644 --- a/.github/workflows/build-number.yml +++ b/.github/workflows/build-number.yml @@ -13,9 +13,9 @@ 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: @@ -23,7 +23,7 @@ jobs: 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: diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 5c744b4..3a93b07 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - ci-version-code # TODO: this is a temporary branch for testing (REMOVE) pull_request: concurrency: diff --git a/build.gradle.kts b/build.gradle.kts index 2b7245d..9a498a4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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").map { it.toInt() }.getOrElse(1) +val versionName = "$versionMajor.$versionMinor.$versionPatch" group = "com.greenmiststudios" version = "1.0-SNAPSHOT" @@ -24,6 +29,9 @@ plugins { } allprojects { + ext.set("version", versionName) + ext.set("versionBuild", versionBuild) + extensions.findByType()?.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 diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index eea3714..25eed6c 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -9,6 +9,8 @@ plugins { alias(libs.plugins.spotless) } +val projectVersion = project.ext.get("version")?.toString() + kotlin { js(IR) { browser { @@ -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() + versionName = projectVersion } packaging { resources { @@ -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 } } } diff --git a/scripts/build-number.sh b/scripts/build-number.sh index 28a0bed..db6c979 100755 --- a/scripts/build-number.sh +++ b/scripts/build-number.sh @@ -1,6 +1,4 @@ #!/bin/bash -set -x - TAGS=$(git show-ref --tags) function getBuildNumberTag { @@ -42,4 +40,5 @@ else echo "Skipping tag creation." fi -echo "BUILD_NUMBER=$CURRENT_BUILD_NUMBER" >> "$GITHUB_ENV" \ No newline at end of file +echo "BUILD_NUMBER=$CURRENT_BUILD_NUMBER" >> "$GITHUB_ENV" +echo "BUILD_NUMBER=$CURRENT_BUILD_NUMBER" >> "$GITHUB_OUTPUT" \ No newline at end of file