diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 818cb7f..ed53548 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -16,6 +16,9 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Get Build Number + uses: ./.github/workflows/build-number.yml + - name: set up JDK 17 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/build-number.yml b/.github/workflows/build-number.yml new file mode 100644 index 0000000..f89a5c5 --- /dev/null +++ b/.github/workflows/build-number.yml @@ -0,0 +1,64 @@ +name: Build Number + +on: + workflow_call: + outputs: + build-number: + description: "The build number generated from git tags on current SHA." + value: ${{ jobs.build-number.outputs.build-number }} + inputs: + token: + description: 'GitHub token or PAT token' + required: false + default: ${{ github.token }} + type: string + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + build-number: + runs-on: ubuntu-latest + outputs: + build_number: ${{ steps.build-number.outputs.build_number }} + steps: + - name: Generate build number + id: build-number + env: + INPUT_GITHUB_TOKEN: ${{ inputs.token }} + run: | + CURRENT_BUILD_NUMBER=$(git show-ref --tags | grep "$GITHUB_SHA" | sort -nr | head -1 | grep -oE "build-number--(\d+)" | grep -oE "\d+") + echo "Found build number $CURRENT_BUILD_NUMBER for current SHA." + + if [ -z "${CURRENT_BUILD_NUMBER}" ]; then + echo "No build number found for current SHA" + + # Get the latest build number + LATEST_BUILD_NUMBER=$(git show-ref --tags | grep -oE "build-number-(\d+)" | sort -nr | head -1 | grep -oE "\d+") + + if [[ -z "${LATEST_BUILD_NUMBER}" ]]; then + echo "No build number found in tags. Please create a tag with the format 'build-number-1' on main branch." + exit 1 + fi + + CURRENT_BUILD_NUMBER="$((LATEST_BUILD_NUMBER + 1))" + git tag "build-number-$CURRENT_BUILD_NUMBER" + + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + GITHUB_URL_PROTOCOL=$(echo "$GITHUB_SERVER_URL" | sed -E "s/https?:\/\///g") + + REMOTE_REPO="${GITHUB_URL_PROTOCOL}//oauth2:${INPUT_GITHUB_TOKEN}@${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git" +# PUSH_PARAMETERS="${REMOTE_REPO} HEAD:${GITHUB_REF}" + PUSH_PARAMETERS="${REMOTE_REPO}" + echo "Pushing build number tag build-number-$CURRENT_BUILD_NUMBER to Github ($GITHUB_REF)." + + git push "$PUSH_PARAMETERS" --tags + else + echo "Skipping tag creation." + exit 0 + fi + + echo "BUILD_NUMBER=$CURRENT_BUILD_NUMBER" > "$GITHUB_ENV" \ No newline at end of file diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 61453fd..b6107eb 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -16,6 +16,9 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Get Build Number + uses: ./.github/workflows/build-number.yml + - name: set up JDK 17 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/desktop-web.yml b/.github/workflows/desktop-web.yml index 1f8dc58..6051d3a 100644 --- a/.github/workflows/desktop-web.yml +++ b/.github/workflows/desktop-web.yml @@ -18,6 +18,9 @@ jobs: - name: Checkout Repo uses: actions/checkout@v4 + - name: Get Build Number + uses: ./.github/workflows/build-number.yml + - name: set up JDK 17 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 48b0a1e..6279f59 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -4,15 +4,15 @@ on: push: branches: - main - - ios-upload-testflight # TODO: this is a temporary branch for testing (REMOVE) + - ci-version-code # TODO: this is a temporary branch for testing (REMOVE) pull_request: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true -jobs: - build: +jobs: + build: runs-on: macos-latest steps: - name: Check Xcode version @@ -21,6 +21,9 @@ jobs: - name: Checkout Repo uses: actions/checkout@v4 + - name: Get Build Number + uses: ./.github/workflows/build-number.yml + - name: Install the Apple certificate and provisioning profile env: BUILD_CERTIFICATE_BASE64: ${{ secrets.IOS_DEV_CERT }} @@ -74,6 +77,20 @@ jobs: with: gradle-home-cache-cleanup: true +# DEBUG: print out all environment variables + - name: Output Run ID + run: echo ${{ github.run_id }} + - name: Output Run Number + run: echo ${{ github.run_number }} + - name: Output Run Attempt + run: echo ${{ github.run_attempt }} + + + + - name: Generate Version Code + run: | + echo "VERSION_CODE=$GITHUB_RUN_NUMBER" >> $GITHUB_ENV + - name: Build Artifact with Xcode run: xcodebuild -project iosApp/iosApp.xcodeproj -scheme iosApp -configuration Debug -destination generic/platform=iOS -archivePath $RUNNER_TEMP/Tidy.xcarchive archive diff --git a/.run/android.run.xml b/.run/android.run.xml deleted file mode 100644 index 4c76b02..0000000 --- a/.run/android.run.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - \ No newline at end of file diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 09a408f..d09da0f 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "com.greenmiststudios.tidy" -version = "${libs.versions.version}-SNAPSHOT" +version = "${project.properties["tidy.version_name"]?.toString()}-SNAPSHOT" @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class) kotlin { diff --git a/composeApp/build.gradle.kts b/composeApp/build.gradle.kts index 1b251df..eea3714 100644 --- a/composeApp/build.gradle.kts +++ b/composeApp/build.gradle.kts @@ -82,8 +82,8 @@ android { applicationId = "com.greenmiststudios.tidy" minSdk = libs.versions.android.minSdk.get().toInt() targetSdk = libs.versions.android.targetSdk.get().toInt() - versionCode = libs.versions.versionCode.get().toInt() - versionName = libs.versions.version.get() + versionCode = project.properties["tidy.version_code"]?.toString()?.toInt() ?: 1 + versionName = project.properties["tidy.version_name"]?.toString() } packaging { resources { @@ -114,7 +114,7 @@ compose.desktop { nativeDistributions { targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) packageName = "com.greenmiststudios.tidy" - packageVersion = libs.versions.version.get() + packageVersion = project.properties["tidy.version_name"]?.toString() } } } diff --git a/gradle.properties b/gradle.properties index 3d8d5b1..69fd7b4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,14 @@ +tidy.version_name=1.0.0 +tidy.version_code=1 + kotlin.code.style=official xcodeproj=iosApp kotlin.native.binary.memoryModel=experimental -org.gradle.jvmargs=-Xmx4096M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx4096M" +org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g -Dkotlin.daemon.jvm.options\="-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g" org.gradle.configuration-cache=true +# Use this flag carefully, in case some of the plugins are not fully compatible. +org.gradle.configuration-cache.problems=warn org.gradle.configureondemand=true org.gradle.java.installations.fromEnv=JDK_17 org.gradle.daemon=true @@ -15,6 +20,7 @@ java.modularToolchainVersion=17 #Android android.nonTransitiveRClass=true android.useAndroidX=true +android.enableJetifier=false #Compose org.jetbrains.compose.experimental.jscanvas.enabled=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a818a05..05ec6db 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,8 +10,6 @@ androidx-compose = "1.5.4" android-compileSdk = "34" android-targetSdk = "34" android-minSdk = "24" -version = "1.0.0" -versionCode = "1" [plugins] android-application = { id = "com.android.application", version.ref = "agp" } @@ -24,6 +22,9 @@ sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" } spotless = { id = "com.diffplug.spotless", version = "6.23.3" } [libraries] +androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.6.1" } +androidx-core = { module = "androidx.core:core-ktx", version = "1.12.0" } +androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.8.2" } compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "androidx-compose" } ktor-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } ktor-core-wasm = { module = "io.ktor:ktor-client-core-wasm", version.ref = "ktor" } @@ -36,9 +37,6 @@ koin-compose = { module = "io.insert-koin:koin-compose", version = "1.1.2" } koin-androidx-compose = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koin" } koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin" } kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version = "1.7.3" } -androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.6.1" } -androidx-core = { module = "androidx.core:core-ktx", version = "1.12.0" } -androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.8.2" } material-compose = { module = "androidx.compose.material3:material3", version = "1.2.0-beta01" } molecule-runtime = { module = "app.cash.molecule:molecule-runtime", version = "1.3.1" } sqldelight-coroutines-extensions = { module = "app.cash.sqldelight:coroutines-extensions", version.ref = "sqldelight" }