From a5ab01ce6809b048eacb396f72ff78c10c12bbdd Mon Sep 17 00:00:00 2001 From: Colin Shelton Date: Mon, 20 May 2024 13:26:39 -0500 Subject: [PATCH] ASAA-221 Desktop target and deploy logic --- .github/auto_assign.yaml | 1 - .github/workflows/gradle-publish.yml | 10 ++++----- gradle/libs.versions.toml | 11 +++++++--- kmp-launchpad-compose/build.gradle.kts | 20 +++++++---------- ...d_Compose.kmp-launchpad-compose.desktop.kt | 22 +++++++++++++++++++ 5 files changed, 43 insertions(+), 21 deletions(-) create mode 100644 kmp-launchpad-compose/src/desktopMain/kotlin/com/bottlerocketstudios/launchpad/compose/util/CurrencyUtils.Launchpad_Compose.kmp-launchpad-compose.desktop.kt diff --git a/.github/auto_assign.yaml b/.github/auto_assign.yaml index 65c45ca..c4ac897 100644 --- a/.github/auto_assign.yaml +++ b/.github/auto_assign.yaml @@ -10,7 +10,6 @@ reviewers: - br-Emery - BottleRocket-Colin - harishrpatel - - MMurrayAtBR # A list of keywords to be skipped the process that add reviewers if pull requests include it skipKeywords: diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 1cfec48..673a282 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -8,10 +8,8 @@ name: Gradle Package on: -# push: -# branches: [ "main" ] -# pull_request: -# branches: [ "main" ] + push: + branches: [ "deploy" ] jobs: build: @@ -36,6 +34,7 @@ jobs: with: arguments: build + # The USERNAME and TOKEN need to correspond to the credentials environment variables used in # the publishing section of your build.gradle - name: Publish to GitHub Packages @@ -43,4 +42,5 @@ jobs: with: arguments: publish env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GH_PUBLISH_USERNAME: ${{ secrets.REPO_READ_WRITE_USER }} + GH_PUBLISH_PASSWORD: ${{ secrets.REPO_READ_WRITE_TOKEN }} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5d09289..0bd8abb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,4 +1,12 @@ [versions] +# Publishing version +launchpad-compose = "0.1.0" + +# Android SDK versions +compile-sdk = "34" +min-sdk = "24" + +# Dependency versions agp = "8.2.2" androidx-window = "1.2.0" compose-plugin = "1.5.12" @@ -7,9 +15,6 @@ kt-lint-gradle = "11.6.1" navigation-compose = "2.7.7" precompose = "1.5.11" -compile-sdk = "34" -min-sdk = "24" -launchpad-compose = "0.0.4" [libraries] androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation-compose" } diff --git a/kmp-launchpad-compose/build.gradle.kts b/kmp-launchpad-compose/build.gradle.kts index f3ba6db..b8f5789 100644 --- a/kmp-launchpad-compose/build.gradle.kts +++ b/kmp-launchpad-compose/build.gradle.kts @@ -21,16 +21,12 @@ kotlin { } } - listOf( - iosX64(), - iosArm64(), - iosSimulatorArm64() - ).forEach { - it.binaries.framework { - baseName = "kmp-launchpad-compose" - isStatic = true - } - } + jvm("desktop") + task("testClasses") + + iosX64() + iosArm64() + iosSimulatorArm64() sourceSets { androidMain.dependencies { @@ -81,8 +77,8 @@ publishing { name = "GitHubPackages" url = uri("https://maven.pkg.github.com/BottleRocketStudios/KMP-LaunchPad-Compose") credentials { - username = System.getenv("REPO_READ_WRITE_USER") - password = System.getenv("REPO_READ_WRITE_TOKEN") + username = System.getenv("REPO_READ_WRITE_USER") ?: System.getenv("GH_PUBLISH_USERNAME") + password = System.getenv("REPO_READ_WRITE_TOKEN") ?: System.getenv("GH_PUBLISH_PASSWORD") } } } diff --git a/kmp-launchpad-compose/src/desktopMain/kotlin/com/bottlerocketstudios/launchpad/compose/util/CurrencyUtils.Launchpad_Compose.kmp-launchpad-compose.desktop.kt b/kmp-launchpad-compose/src/desktopMain/kotlin/com/bottlerocketstudios/launchpad/compose/util/CurrencyUtils.Launchpad_Compose.kmp-launchpad-compose.desktop.kt new file mode 100644 index 0000000..71bcb6d --- /dev/null +++ b/kmp-launchpad-compose/src/desktopMain/kotlin/com/bottlerocketstudios/launchpad/compose/util/CurrencyUtils.Launchpad_Compose.kmp-launchpad-compose.desktop.kt @@ -0,0 +1,22 @@ +package com.bottlerocketstudios.launchpad.compose.util + +import java.text.NumberFormat +import java.util.Currency +import java.util.Locale + +/** + * Kotlin Multiplatform function - convertToCurrencyString + * + * This function takes a Double value representing a raw amount of currency, + * and returns a String representing that amount formatted appropriately as + * currency for the current locale of the device running the code. + * + * @param [amount] The raw amount of currency as a Double + * @return A string representing that amount in the appropriate currency + * format for the device's current locale. + */ +actual fun Double?.toCurrency(): String { + val numberFormat = NumberFormat.getCurrencyInstance() + numberFormat.currency = Currency.getInstance(Locale.getDefault()) + return numberFormat.format(this ?: 0.0) +} \ No newline at end of file