From 6264964367b9c977aeff92df2d8c5e6065f62c31 Mon Sep 17 00:00:00 2001 From: Artem Cheremnov Date: Wed, 13 Dec 2023 10:58:16 +0300 Subject: [PATCH 01/10] Init commit --- .github/android-sdk.yml | 83 +++++++++++++++++++++++++++++++++++++++++ VCL/build.gradle | 82 +++++++++++++++++++++++++++++++++++----- build.gradle | 3 +- publish-core.gradle | 35 +++++++++++------ 4 files changed, 181 insertions(+), 22 deletions(-) create mode 100644 .github/android-sdk.yml diff --git a/.github/android-sdk.yml b/.github/android-sdk.yml new file mode 100644 index 00000000..44423aec --- /dev/null +++ b/.github/android-sdk.yml @@ -0,0 +1,83 @@ +name: WalletAndroid-SDK + +on: + push: + branches: + - main + - staging + - dev +env: + PACKAGE_TYPE: "aar" + GRADLE_VERSION: "7.5" + JAVA_VERSION: "11" + ARTIFACT_PATH: "VCL/build/outputs" + ANDROID_NEXUS_SIGNING_KEY_ID: ${{ secrets.ANDROID_NEXUS_SIGNING_KEY_ID }} + ANDROID_NEXUS_SIGNING_PWD: ${{ secrets.ANDROID_NEXUS_SIGNING_PWD }} + ANDROID_NEXUS_OSSRH_USERNAME: ${{ secrets.ANDROID_NEXUS_OSSRH_USERNAME }} + ANDROID_NEXUS_OSSRH_PWD: ${{ secrets.ANDROID_NEXUS_OSSRH_PWD }} + ANDROID_NEXUS_STAGING_PROFILE_ID: ${{ secrets.ANDROID_NEXUS_STAGING_PROFILE_ID }} + ANDROID_NEXUS_PRIVATE_KEY: ${{ secrets.ANDROID_NEXUS_PRIVATE_KEY }} +jobs: + test-android-sdk: + runs-on: ubuntu-latest + steps: + - name: Git clone repository + uses: actions/checkout@v4 + # Setup java + - uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: ${{ env.JAVA_VERSION }} + # Run test + - name: Run Test + run: ./gradlew test + + build-android-sdk: + runs-on: ubuntu-latest + needs: + - test-android-sdk + steps: + - name: Git clone repository + uses: actions/checkout@v4 + # Setup java + - uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: ${{ env.JAVA_VERSION }} + # Gradle Assemble + - name: Gradle Assemble + run: ./gradlew assemble${{ env.RELEASE_TAG }} + env: + RELEASE_TAG: ${{ github.ref == 'refs/heads/main' && format('{0}', 'Release' ) || 'Rc' }} + # Convert artifact to lowercase + - name: Rename artifact to lowercase + run: mv ${{ env.ARTIFACT_PATH}}/${{ env.PACKAGE_TYPE }}/VCL-${{ env.RELEASE_TAG }}.${{ env.PACKAGE_TYPE }} ${{ env.ARTIFACT_PATH }}/${{ env.PACKAGE_TYPE }}/vcl-${{ env.RELEASE_TAG }}.${{ env.PACKAGE_TYPE }} + env: + RELEASE_TAG: ${{ github.ref == 'refs/heads/main' && format('{0}', 'release' ) || 'rc' }} + # Show Me Builded packages + - name: Show Me Builded packages + run: ls -al ${{ env.ARTIFACT_PATH}}/${{ env.PACKAGE_TYPE }}/ + # Publish Main/Staging + - name: Publish Main/Staging + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' }} + run: ./gradlew publish${{ env.RELEASE_TAG }} + env: + RELEASE_TAG: ${{ github.ref == 'refs/heads/main' && format('{0}', 'Release' ) || 'Rc' }} + # Upload Artifacts + - name: Upload Artifact + if: success() + uses: actions/upload-artifact@v3 + with: + name: vcl-${{ env.RELEASE_TAG }}.${{ env.PACKAGE_TYPE }} + path: ${{ env.ARTIFACT_PATH }}/${{ env.PACKAGE_TYPE }} + if-no-files-found: error + retention-days: 1 + env: + RELEASE_TAG: ${{ github.ref == 'refs/heads/main' && format('{0}', 'release' ) || 'rc' }} + + + + + + + diff --git a/VCL/build.gradle b/VCL/build.gradle index 05944349..9d5ad6f6 100644 --- a/VCL/build.gradle +++ b/VCL/build.gradle @@ -13,7 +13,8 @@ android { defaultConfig { minSdk 24 targetSdk 33 - versionName "1.21.0" + // Increase version for release + versionName "1.20.2" versionCode 116 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -41,6 +42,13 @@ android { shrinkResources false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } + rc { + buildConfigField "String", "VERSION_NAME", "\"${defaultConfig.versionName}-rc\"" + buildConfigField "int", "VERSION_CODE", "${defaultConfig.versionCode}" + minifyEnabled false + shrinkResources false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } } compileOptions { @@ -96,6 +104,61 @@ artifacts { afterEvaluate { publishing { publications { + rc(MavenPublication) { + groupId getGroupId() + artifactId getArtifactId() + + // define rc version name + def rc = getVersionName() + version = "${rc}-RC" + + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + from components.release + } else { + from components.java + } + + artifact androidSourcesJar + + // Mostly self-explanatory metadata + pom { + name = getArtifactId() + // Library description + description = 'Velocity Career Labs Android library' + // Library Github URL + url = 'https://github.com/velocitycareerlabs/WalletAndroid' + licenses { + license { + name = 'Apache License 2.0' + // Library license + url = 'https://github.com/velocitycareerlabs/WalletAndroid/blob/dev/VCL/LICENSE' + } + } + developers { + developer { + id = 'velocitycareerlabs' + name = 'Michael Avoyan' + email = 'michael.avoyan@velocitycareerlabs.com' + } + } + + scm { + // Library info on Github + connection = 'scm:github.com/velocitycareerlabs/WalletAndroid.git' + developerConnection = 'scm:git:ssh://github.com/velocitycareerlabs/WalletAndroid.git' + url = 'https://github.com/velocitycareerlabs/WalletAndroid' + } + } + signing { + useInMemoryPgpKeys( + rootProject.ext.signingKeyId, + rootProject.ext.signingPrivateKey, + rootProject.ext.signingPassword, + ) + // sign publishing.publications + } + } release(MavenPublication) { groupId getGroupId() artifactId getArtifactId() @@ -139,20 +202,19 @@ afterEvaluate { url = 'https://github.com/velocitycareerlabs/WalletAndroid' } } + signing { + useInMemoryPgpKeys( + rootProject.ext.signingKeyId, + rootProject.ext.signingPrivateKey, + rootProject.ext.signingPassword, + ) + // sign publishing.publications + } } } } } -signing { - useInMemoryPgpKeys( - rootProject.ext.signingKeyId, - rootProject.ext.signingPrivateKey, - rootProject.ext.signingPassword, - ) - sign publishing.publications -} - repositories { mavenCentral() } diff --git a/build.gradle b/build.gradle index 44460111..181a18cb 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ buildscript { plugins { // Automation plugin + // https://github.com/gradle-nexus/publish-plugin id "io.github.gradle-nexus.publish-plugin" version "1.1.0" } @@ -35,4 +36,4 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir -} \ No newline at end of file +} diff --git a/publish-core.gradle b/publish-core.gradle index 48de19a5..88e0765b 100644 --- a/publish-core.gradle +++ b/publish-core.gradle @@ -1,7 +1,16 @@ -Properties properties = new Properties() -properties.load(new FileInputStream(rootProject.file( - '/Volumes/Keybase/team/velocitycareers/mobile/android/maven/nexus.properties' -))) +def propertiesFilePath = '/Volumes/Keybase/team/velocitycareers/mobile/android/maven/nexus.properties' +def propertiesFile = new File(propertiesFilePath) + +if (propertiesFile.exists()) { + def properties = new Properties() + try { + properties.load(new FileInputStream(propertiesFile)) + } catch (IOException e) { + e.printStackTrace() + } +} else { + println "Properties file not found: $propertiesFilePath" +} ext { signingKeyId = System.getenv("ANDROID_NEXUS_SIGNING_KEY_ID") ?: properties["signingKeyId"] @@ -12,12 +21,12 @@ ext { signingPrivateKey = System.getenv("ANDROID_NEXUS_PRIVATE_KEY") ?: properties["signingPrivateKey"] } -//println("signingKeyId: ${signingKeyId}") -//println("signingPassword: ${signingPassword}") -//println("ossrhUsername: ${ossrhUsername}") -//println("ossrhPassword: ${ossrhPassword}") -//println("sonatypeStagingProfileId: ${sonatypeStagingProfileId}") -//println("signingPrivateKey: ${signingPrivateKey}") +// println("signingKeyId: ${signingKeyId}") +// println("signingPassword: ${signingPassword}") +// println("ossrhUsername: ${ossrhUsername}") +// println("ossrhPassword: ${ossrhPassword}") +// println("sonatypeStagingProfileId: ${sonatypeStagingProfileId}") +// println("signingPrivateKey: ${signingPrivateKey}") nexusPublishing { repositories { @@ -29,4 +38,8 @@ nexusPublishing { snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) } } -} \ No newline at end of file +} + +// Create custom tasks for publishing +task publishRelease(dependsOn: [':VCL:publishReleasePublicationToSonatypeRepository']) +task publishRc(dependsOn: [':VCL:publishRcPublicationToSonatypeRepository']) \ No newline at end of file From 3ddc2edeaa97cd03b7163feb0afa45f58ca676f0 Mon Sep 17 00:00:00 2001 From: Artem Cheremnov Date: Wed, 13 Dec 2023 11:23:00 +0300 Subject: [PATCH 02/10] Increase java version to 17; run again --- .github/{ => workflows}/android-sdk.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename .github/{ => workflows}/android-sdk.yml (96%) diff --git a/.github/android-sdk.yml b/.github/workflows/android-sdk.yml similarity index 96% rename from .github/android-sdk.yml rename to .github/workflows/android-sdk.yml index 44423aec..2d7960a4 100644 --- a/.github/android-sdk.yml +++ b/.github/workflows/android-sdk.yml @@ -6,10 +6,11 @@ on: - main - staging - dev + - VL-6481 env: PACKAGE_TYPE: "aar" GRADLE_VERSION: "7.5" - JAVA_VERSION: "11" + JAVA_VERSION: "17" ARTIFACT_PATH: "VCL/build/outputs" ANDROID_NEXUS_SIGNING_KEY_ID: ${{ secrets.ANDROID_NEXUS_SIGNING_KEY_ID }} ANDROID_NEXUS_SIGNING_PWD: ${{ secrets.ANDROID_NEXUS_SIGNING_PWD }} @@ -59,7 +60,7 @@ jobs: run: ls -al ${{ env.ARTIFACT_PATH}}/${{ env.PACKAGE_TYPE }}/ # Publish Main/Staging - name: Publish Main/Staging - if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' }} + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/VL-6481' }} run: ./gradlew publish${{ env.RELEASE_TAG }} env: RELEASE_TAG: ${{ github.ref == 'refs/heads/main' && format('{0}', 'Release' ) || 'Rc' }} From 11368435429ee3a023a2c9a23435458ffbdcb242 Mon Sep 17 00:00:00 2001 From: Artem Cheremnov Date: Wed, 13 Dec 2023 11:26:35 +0300 Subject: [PATCH 03/10] rcSuffix in defaultConfig --- VCL/build.gradle | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/VCL/build.gradle b/VCL/build.gradle index 9d5ad6f6..d17be24d 100644 --- a/VCL/build.gradle +++ b/VCL/build.gradle @@ -15,6 +15,8 @@ android { targetSdk 33 // Increase version for release versionName "1.20.2" + // Set RC suffix for release candidate + rcSuffix "RC" versionCode 116 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -84,6 +86,10 @@ def getGroupId = { -> return 'io.velocitycareerlabs' } +def getRcSuffix = { -> + return android.defaultConfig.rcSuffix +} + tasks.register('androidSourcesJar', Jar) { archiveClassifier.set('sources') if (project.plugins.findPlugin("com.android.library")) { @@ -110,7 +116,8 @@ afterEvaluate { // define rc version name def rc = getVersionName() - version = "${rc}-RC" + def suffix = getRcSuffix() + version = "${rc}-${suffix}" // Two artifacts, the `aar` (or `jar`) and the sources if (project.plugins.findPlugin("com.android.library")) { From db9c35970b944eb485dc1b39c6c3dc2b4e640a88 Mon Sep 17 00:00:00 2001 From: Artem Cheremnov Date: Wed, 13 Dec 2023 11:30:12 +0300 Subject: [PATCH 04/10] rcSuffix in defaultConfig; fix --- VCL/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VCL/build.gradle b/VCL/build.gradle index d17be24d..33e1a1f7 100644 --- a/VCL/build.gradle +++ b/VCL/build.gradle @@ -16,7 +16,7 @@ android { // Increase version for release versionName "1.20.2" // Set RC suffix for release candidate - rcSuffix "RC" + def rcSuffix = "RC" versionCode 116 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" From 5daf23e7f168a78a14281ade201ded4c4e1bafd6 Mon Sep 17 00:00:00 2001 From: Artem Cheremnov Date: Wed, 13 Dec 2023 11:35:21 +0300 Subject: [PATCH 05/10] rcSuffix in defaultConfig; fix #2 --- VCL/build.gradle | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/VCL/build.gradle b/VCL/build.gradle index 33e1a1f7..2b2e3c18 100644 --- a/VCL/build.gradle +++ b/VCL/build.gradle @@ -10,13 +10,16 @@ android { // buildToolsVersion "30.0.3" namespace 'io.velocitycareerlabs' + ext { + // Set RC suffix for release candidate + rcSuffix = "RC" + } + defaultConfig { minSdk 24 targetSdk 33 // Increase version for release versionName "1.20.2" - // Set RC suffix for release candidate - def rcSuffix = "RC" versionCode 116 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -86,10 +89,6 @@ def getGroupId = { -> return 'io.velocitycareerlabs' } -def getRcSuffix = { -> - return android.defaultConfig.rcSuffix -} - tasks.register('androidSourcesJar', Jar) { archiveClassifier.set('sources') if (project.plugins.findPlugin("com.android.library")) { @@ -115,9 +114,9 @@ afterEvaluate { artifactId getArtifactId() // define rc version name - def rc = getVersionName() - def suffix = getRcSuffix() - version = "${rc}-${suffix}" + def vers = getVersionName() + def rcSuffix = ext.rcSuffix + version = "${vers}-${rcSuffix}" // Two artifacts, the `aar` (or `jar`) and the sources if (project.plugins.findPlugin("com.android.library")) { From 89c9cd442a6d7112be0c603bcb6af5d29ca7c361 Mon Sep 17 00:00:00 2001 From: Artem Cheremnov Date: Wed, 13 Dec 2023 11:42:14 +0300 Subject: [PATCH 06/10] rcSuffix in defaultConfig; fix #3 --- VCL/build.gradle | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/VCL/build.gradle b/VCL/build.gradle index 2b2e3c18..30caf230 100644 --- a/VCL/build.gradle +++ b/VCL/build.gradle @@ -5,16 +5,16 @@ plugins { id 'signing' } +ext { + // Set RC suffix for release candidate + rcSuffix = "RC" +} + android { compileSdk 33 // buildToolsVersion "30.0.3" namespace 'io.velocitycareerlabs' - ext { - // Set RC suffix for release candidate - rcSuffix = "RC" - } - defaultConfig { minSdk 24 targetSdk 33 From 7db4852fdb4f0297cceae79192c3d88d93c61684 Mon Sep 17 00:00:00 2001 From: Michael Avoyan Date: Wed, 13 Dec 2023 10:58:57 +0200 Subject: [PATCH 07/10] fix: Set rc suffix for VCL SDK release candidate --- VCL/build.gradle | 7 +------ build.gradle | 2 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/VCL/build.gradle b/VCL/build.gradle index 30caf230..d18faadd 100644 --- a/VCL/build.gradle +++ b/VCL/build.gradle @@ -5,11 +5,6 @@ plugins { id 'signing' } -ext { - // Set RC suffix for release candidate - rcSuffix = "RC" -} - android { compileSdk 33 // buildToolsVersion "30.0.3" @@ -115,7 +110,7 @@ afterEvaluate { // define rc version name def vers = getVersionName() - def rcSuffix = ext.rcSuffix + def rcSuffix = rootProject.ext.rcSuffix version = "${vers}-${rcSuffix}" // Two artifacts, the `aar` (or `jar`) and the sources diff --git a/build.gradle b/build.gradle index 181a18cb..07aca28b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,8 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = "1.7.21" + // Set "rc" suffix for VCL SDK release candidate + ext.rcSuffix = "rc" repositories { google() mavenCentral() From fc237868a31271b9709a2f536aadad0b62af39f6 Mon Sep 17 00:00:00 2001 From: Artem Cheremnov Date: Wed, 13 Dec 2023 12:01:03 +0300 Subject: [PATCH 08/10] disable build on task branch; ready for merge --- .github/workflows/android-sdk.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/android-sdk.yml b/.github/workflows/android-sdk.yml index 2d7960a4..84a6e925 100644 --- a/.github/workflows/android-sdk.yml +++ b/.github/workflows/android-sdk.yml @@ -6,7 +6,6 @@ on: - main - staging - dev - - VL-6481 env: PACKAGE_TYPE: "aar" GRADLE_VERSION: "7.5" @@ -60,7 +59,7 @@ jobs: run: ls -al ${{ env.ARTIFACT_PATH}}/${{ env.PACKAGE_TYPE }}/ # Publish Main/Staging - name: Publish Main/Staging - if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/VL-6481' }} + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' }} run: ./gradlew publish${{ env.RELEASE_TAG }} env: RELEASE_TAG: ${{ github.ref == 'refs/heads/main' && format('{0}', 'Release' ) || 'Rc' }} From d2e43f38571597ff3c47fbe3b97470514a7796dd Mon Sep 17 00:00:00 2001 From: Michael Avoyan Date: Wed, 13 Dec 2023 12:59:18 +0200 Subject: [PATCH 09/10] fix gradle --- VCL/build.gradle | 2 +- publish-core.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VCL/build.gradle b/VCL/build.gradle index d18faadd..aae89b29 100644 --- a/VCL/build.gradle +++ b/VCL/build.gradle @@ -14,7 +14,7 @@ android { minSdk 24 targetSdk 33 // Increase version for release - versionName "1.20.2" + versionName "1.20.1" versionCode 116 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" diff --git a/publish-core.gradle b/publish-core.gradle index 88e0765b..f4c10a5f 100644 --- a/publish-core.gradle +++ b/publish-core.gradle @@ -1,8 +1,8 @@ def propertiesFilePath = '/Volumes/Keybase/team/velocitycareers/mobile/android/maven/nexus.properties' def propertiesFile = new File(propertiesFilePath) +def properties = new Properties() if (propertiesFile.exists()) { - def properties = new Properties() try { properties.load(new FileInputStream(propertiesFile)) } catch (IOException e) { From 2ee1773a087caf04ea204a126c8a6ef77b90490a Mon Sep 17 00:00:00 2001 From: Artem Cheremnov Date: Wed, 13 Dec 2023 14:01:22 +0300 Subject: [PATCH 10/10] Fix publish-core.gradle properties; rc branch instead staging --- .github/workflows/android-sdk.yml | 8 ++++---- publish-core.gradle | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/android-sdk.yml b/.github/workflows/android-sdk.yml index 84a6e925..0b7c486c 100644 --- a/.github/workflows/android-sdk.yml +++ b/.github/workflows/android-sdk.yml @@ -4,7 +4,7 @@ on: push: branches: - main - - staging + - rc - dev env: PACKAGE_TYPE: "aar" @@ -57,9 +57,9 @@ jobs: # Show Me Builded packages - name: Show Me Builded packages run: ls -al ${{ env.ARTIFACT_PATH}}/${{ env.PACKAGE_TYPE }}/ - # Publish Main/Staging - - name: Publish Main/Staging - if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' }} + # Publish Main/Rc + - name: Publish Main/Rc + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' }} run: ./gradlew publish${{ env.RELEASE_TAG }} env: RELEASE_TAG: ${{ github.ref == 'refs/heads/main' && format('{0}', 'Release' ) || 'Rc' }} diff --git a/publish-core.gradle b/publish-core.gradle index f4c10a5f..2685c325 100644 --- a/publish-core.gradle +++ b/publish-core.gradle @@ -1,8 +1,8 @@ def propertiesFilePath = '/Volumes/Keybase/team/velocitycareers/mobile/android/maven/nexus.properties' def propertiesFile = new File(propertiesFilePath) - def properties = new Properties() -if (propertiesFile.exists()) { + +if (propertiesFile.exists()) { try { properties.load(new FileInputStream(propertiesFile)) } catch (IOException e) {