diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a496395..a5ae9a3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,55 +1,96 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - name: Deploy to central -on: workflow_dispatch +on: + release: + types: + - published + +concurrency: + group: release + cancel-in-progress: true permissions: - contents: read + contents: write jobs: - deploy: + deploy-sdk: + name: Deploy SDK strategy: matrix: include: -# - target: publishIosArm64PublicationToSonatypeRepository -# os: macos-latest + # - target: publishIosArm64PublicationToSonatypeRepository + # os: macos-latest - target: :shared:publishAllPublicationsToMavenCentralRepository os: ubuntu-latest - target: :android:publishAllPublicationsToMavenCentralRepository os: ubuntu-latest runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v3 - - uses: actions/cache@v4 - with: - path: | - ~/.konan - key: ${{ runner.os }}-${{ hashFiles('**/.lock') }} - - name: Import GPG key - uses: crazy-max/ghaction-import-gpg@v6 - with: - gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} - passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - - name: Deploy - uses: gradle/gradle-build-action@v3 - with: - arguments: ${{ matrix.target }} --no-configuration-cache --no-daemon - env: - ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} - ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} - ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MEMORY_KEY }} - ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} + - uses: actions/checkout@v4 + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v3 + - uses: actions/cache@v4 + with: + path: | + ~/.konan + key: ${{ runner.os }}-${{ hashFiles('**/.lock') }} + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} + passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 + - name: Write release version + run: | + TAG=${{ github.event.release.tag_name }} + echo Version: TAG + echo "SDK_VERSION=${TAG#v}" >> $GITHUB_ENV + + - name: Deploy + run: chmod +x gradlew && ./gradlew ${{ matrix.target }} --no-configuration-cache --no-daemon + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MEMORY_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} + SDK_VERSION: ${{ env.SDK_VERSION }} + + deploy-app: + name: Deploy Android App + needs: deploy-sdk + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 17 + - name: Write release version + run: | + TAG=${{ github.event.release.tag_name }} + echo Version: TAG + echo "SDK_VERSION=${TAG#v}" >> $GITHUB_ENV + - name: Setup local.properties + run: | + touch local.properties + echo "TEST_SERVER_URL=${{ secrets.TEST_SERVER_URL }}" >> local.properties + cat local.properties + - name: Build SoundBud! + run: ./gradlew :example-android:assembleDevRelease + - name: Publish SoundBud! + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: example-android/build/outputs/apk/dev/release/example-android-dev-release.apk + asset_name: soundBud-release.apk + make_latest: false + env: + SDK_VERSION: ${{ env.SDK_VERSION }} \ No newline at end of file diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml deleted file mode 100644 index 88dce4d..0000000 --- a/.github/workflows/gradle.yml +++ /dev/null @@ -1,50 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - -name: Java CI with Gradle - -on: -# push: -# branches: [ "main" ] -# pull_request: -# branches: [ "main" ] - workflow_call: - -permissions: - contents: read - -jobs: - build: - strategy: - matrix: - include: -# - target: iosSimulatorArm64Test -# os: macos-latest - - target: testDebugUnitTest - os: ubuntu-latest - - target: testReleaseUnitTest - os: ubuntu-latest - runs-on: ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - - name: Validate Gradle Wrapper - uses: gradle/wrapper-validation-action@v3 - - uses: actions/cache@v4 - with: - path: | - ~/.konan - key: ${{ runner.os }}-${{ hashFiles('**/.lock') }} - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - - name: Build with Gradle - uses: gradle/gradle-build-action@ce999babab2de1c4b649dc15f0ee67e6246c994f - with: - arguments: ${{ matrix.target }} diff --git a/README.md b/README.md index 5ac36ed..c2c46dc 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ The Android SDK utilize the latest version of jetpack compose. #### Setup ```kotlin dependencies { - implementation("com.komoju.mobile.sdk:android:0.0.1") + implementation("com.komoju.mobile.sdk:android:") } ``` diff --git a/android/build.gradle.kts b/android/build.gradle.kts index da8d179..4e750dc 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -82,7 +82,7 @@ dependencies { mavenPublishing { publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) signAllPublications() - coordinates(groupId = "com.komoju.mobile.sdk", artifactId = "android", version = "0.0.1") + coordinates(groupId = "com.komoju.mobile.sdk", artifactId = "android", version = (System.getenv("SDK_VERSION") ?: "0.0.1")) pom { name.set("Komoju Mobile SDK For Android") description.set("Komoju Mobile SDK For Android") @@ -118,7 +118,6 @@ tasks.matching { task -> tasks.withType().configureEach { moduleName.set("Komoju Android SDK Documentation") - moduleVersion.set("v0.0.1") outputDirectory.set(layout.projectDirectory.dir("docs/")) dokkaSourceSets.configureEach { displayName.set("Android") diff --git a/android/consumer-rules.pro b/android/consumer-rules.pro index e69de29..5d89de1 100644 --- a/android/consumer-rules.pro +++ b/android/consumer-rules.pro @@ -0,0 +1 @@ +-keep class com.komoju.mobile.sdk.remote.dtos.** { *; } \ No newline at end of file diff --git a/example-android/build.gradle.kts b/example-android/build.gradle.kts index fde7ae6..0a03c2b 100644 --- a/example-android/build.gradle.kts +++ b/example-android/build.gradle.kts @@ -20,14 +20,16 @@ android { minSdk = 24 targetSdk = 35 versionCode = 1 - versionName = "1.0" + versionName = System.getenv("VERSION") ?: "1.0" resValue("string", "komoju_consumer_app_scheme", "komapp") testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + signingConfig = signingConfigs.getByName("debug") } buildTypes { release { - isMinifyEnabled = false + isMinifyEnabled = true + isShrinkResources = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro", diff --git a/example-android/proguard-rules.pro b/example-android/proguard-rules.pro index 481bb43..fc37667 100644 --- a/example-android/proguard-rules.pro +++ b/example-android/proguard-rules.pro @@ -18,4 +18,6 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-keep class com.komoju.android.ui.remote.dtos.** { *; } \ No newline at end of file diff --git a/example-android/src/main/AndroidManifest.xml b/example-android/src/main/AndroidManifest.xml index 1b129c1..be46e7f 100644 --- a/example-android/src/main/AndroidManifest.xml +++ b/example-android/src/main/AndroidManifest.xml @@ -6,7 +6,6 @@ android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" - android:networkSecurityConfig="@xml/network_security_config" android:roundIcon="@mipmap/ic_launcher_round" android:theme="@style/Theme.FakeShopApp"> if (publishableKey == null) { - _uiState.update { it.copy(error = "Failed to fetch publishable key.") } + _uiState.update { it.copy(error = "Failed to fetch publishable key from Server ${BuildConfig.SERVER_URL}") } } }.onFailure { error -> + error.printStackTrace() _uiState.update { it.copy(error = "Failed to fetch publishable key.\n${error.message}") } }.getOrNull() diff --git a/example-android/src/main/res/xml/network_security_config.xml b/example-android/src/main/res/xml/network_security_config.xml deleted file mode 100644 index 6d611ba..0000000 --- a/example-android/src/main/res/xml/network_security_config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index cb271a9..fd61407 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -64,7 +64,7 @@ android { mavenPublishing { publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) signAllPublications() - coordinates(groupId = "com.komoju.mobile.sdk", artifactId = "shared", version = "0.0.1") + coordinates(groupId = "com.komoju.mobile.sdk", artifactId = "shared", version = (System.getenv("SDK_VERSION") ?: "0.0.1")) pom { name.set("Komoju Mobile SDK") description.set("Komoju Payment SDK for Mobile")