diff --git a/.github/workflows/android-sdk-tests.yml b/.github/workflows/android-sdk-tests.yml index bd097f9..6104ef8 100644 --- a/.github/workflows/android-sdk-tests.yml +++ b/.github/workflows/android-sdk-tests.yml @@ -11,6 +11,12 @@ env: GRADLE_VERSION: "8.4" JAVA_VERSION: "17" ARTIFACT_PATH: "VCL/build/outputs" + ANDROID_NEXUS_OSSRH_TOKEN_USERNAME: ${{ secrets.ANDROID_NEXUS_OSSRH_TOKEN_USERNAME }} + ANDROID_NEXUS_OSSRH_TOKEN_PASSWORD: ${{ secrets.ANDROID_NEXUS_OSSRH_TOKEN_PASSWORD }} + ANDROID_NEXUS_SIGNING_KEY_ID: ${{ secrets.ANDROID_NEXUS_SIGNING_KEY_ID }} + ANDROID_NEXUS_SIGNING_PASSWORD: ${{ secrets.ANDROID_NEXUS_SIGNING_PASSWORD }} + 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 diff --git a/.github/workflows/android-sdk.yml b/.github/workflows/android-sdk.yml index 6b62e0c..46c6647 100644 --- a/.github/workflows/android-sdk.yml +++ b/.github/workflows/android-sdk.yml @@ -55,12 +55,6 @@ jobs: run: ./gradlew assemble${{ env.RELEASE_TAG }} env: RELEASE_TAG: ${{ env.GLOBAL_ENV == 'prod' && format('{0}', 'Release' ) || 'Rc' }} - ANDROID_NEXUS_OSSRH_TOKEN_USERNAME: ${{ secrets.ANDROID_NEXUS_OSSRH_TOKEN_USERNAME }} - ANDROID_NEXUS_OSSRH_TOKEN_PASSWORD: ${{ secrets.ANDROID_NEXUS_OSSRH_TOKEN_PASSWORD }} - ANDROID_NEXUS_SIGNING_KEY_ID: ${{ secrets.ANDROID_NEXUS_SIGNING_KEY_ID }} - ANDROID_NEXUS_SIGNING_PASSWORD: ${{ secrets.ANDROID_NEXUS_SIGNING_PASSWORD }} - ANDROID_NEXUS_STAGING_PROFILE_ID: ${{ secrets.ANDROID_NEXUS_STAGING_PROFILE_ID }} - ANDROID_NEXUS_PRIVATE_KEY: ${{ secrets.ANDROID_NEXUS_PRIVATE_KEY }} # 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 }} @@ -82,7 +76,6 @@ jobs: ANDROID_NEXUS_SIGNING_KEY_ID: ${{ secrets.ANDROID_NEXUS_SIGNING_KEY_ID }} ANDROID_NEXUS_SIGNING_PASSWORD: ${{ secrets.ANDROID_NEXUS_SIGNING_PASSWORD }} ANDROID_NEXUS_STAGING_PROFILE_ID: ${{ secrets.ANDROID_NEXUS_STAGING_PROFILE_ID }} - ANDROID_NEXUS_PRIVATE_KEY: ${{ secrets.ANDROID_NEXUS_PRIVATE_KEY }} # Upload Artifacts - name: Upload Artifact if: success() diff --git a/VCL/build.gradle b/VCL/build.gradle index 7a199cd..51fd75e 100644 --- a/VCL/build.gradle +++ b/VCL/build.gradle @@ -7,7 +7,6 @@ plugins { android { compileSdk 34 -// buildToolsVersion "30.0.3" namespace 'io.velocitycareerlabs' defaultConfig { @@ -88,31 +87,23 @@ def getGroupId = { -> tasks.register('androidSourcesJar', Jar) { archiveClassifier.set('sources') - if (project.plugins.findPlugin("com.android.library")) { - // For Android libraries - from android.sourceSets.main.java.srcDirs - from android.sourceSets.main.kotlin.srcDirs - } else { - // For pure Kotlin libraries, in case you have them - from sourceSets.main.java.srcDirs - from sourceSets.main.kotlin.srcDirs - } + from android.sourceSets.main.java.srcDirs + from android.sourceSets.main.kotlin.srcDirs } artifacts { - archives androidSourcesJar + archives tasks.named('androidSourcesJar') } afterEvaluate { publishing { publications { - rc(MavenPublication) { - groupId getGroupId() - artifactId getArtifactId() - version getVersionName() + create('rc', MavenPublication) { + groupId = getGroupId() + artifactId = getArtifactId() + version = getVersionName() - // Main artifact - if (project.plugins.findPlugin("com.android.library")) { + if (project.plugins.hasPlugin("com.android.library")) { artifact("$buildDir/outputs/aar/${project.name}-release.aar") { builtBy tasks.named('assembleRelease') } @@ -122,46 +113,38 @@ afterEvaluate { } } - // Sources jar artifact artifact(tasks.named('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' + name.set(getArtifactId()) + description.set('Velocity Career Labs Android library') + url.set('https://github.com/velocitycareerlabs/WalletAndroid') licenses { license { - name = 'Apache License 2.0' - // Library license - url = 'https://github.com/velocitycareerlabs/WalletAndroid/blob/dev/VCL/LICENSE' + name.set('Apache License 2.0') + url.set('https://github.com/velocitycareerlabs/WalletAndroid/blob/dev/VCL/LICENSE') } } developers { developer { - id = 'velocitycareerlabs' - name = 'Michael Avoyan' - email = 'michael.avoyan@velocitycareerlabs.com' + id.set('velocitycareerlabs') + name.set('Michael Avoyan') + email.set('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' + connection.set('scm:github.com/velocitycareerlabs/WalletAndroid.git') + developerConnection.set('scm:git:ssh://github.com/velocitycareerlabs/WalletAndroid.git') + url.set('https://github.com/velocitycareerlabs/WalletAndroid') } } } - release(MavenPublication) { - groupId getGroupId() - artifactId getArtifactId() - version getVersionName() + create('release', MavenPublication) { + groupId = getGroupId() + artifactId = getArtifactId() + version = getVersionName() - // Main artifact - if (project.plugins.findPlugin("com.android.library")) { + if (project.plugins.hasPlugin("com.android.library")) { artifact("$buildDir/outputs/aar/${project.name}-release.aar") { builtBy tasks.named('assembleRelease') } @@ -171,36 +154,29 @@ afterEvaluate { } } - // Sources jar artifact artifact(tasks.named('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' + name.set(getArtifactId()) + description.set('Velocity Career Labs Android library') + url.set('https://github.com/velocitycareerlabs/WalletAndroid') licenses { license { - name = 'Apache License 2.0' - // Library license - url = 'https://github.com/velocitycareerlabs/WalletAndroid/blob/dev/VCL/LICENSE' + name.set('Apache License 2.0') + url.set('https://github.com/velocitycareerlabs/WalletAndroid/blob/dev/VCL/LICENSE') } } developers { developer { - id = 'velocitycareerlabs' - name = 'Michael Avoyan' - email = 'michael.avoyan@velocitycareerlabs.com' + id.set('velocitycareerlabs') + name.set('Michael Avoyan') + email.set('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' + connection.set('scm:github.com/velocitycareerlabs/WalletAndroid.git') + developerConnection.set('scm:git:ssh://github.com/velocitycareerlabs/WalletAndroid.git') + url.set('https://github.com/velocitycareerlabs/WalletAndroid') } } } @@ -213,21 +189,23 @@ afterEvaluate { rootProject.ext.signingPrivateKey, rootProject.ext.signingPassword ) - sign publishing.publications + sign(publishing.publications) +// sign(publishing.publications['rc']) +// sign(publishing.publications['release']) } tasks.named('generateMetadataFileForRcPublication') { - dependsOn tasks.named('androidSourcesJar') + dependsOn(tasks.named('androidSourcesJar')) } - tasks.named("publishRcPublicationToSonatypeRepository").configure { - dependsOn tasks.named("signRcPublication") - dependsOn tasks.named("signReleasePublication") + tasks.named("publishRcPublicationToSonatypeRepository") { + dependsOn(tasks.named("signRcPublication")) + dependsOn(tasks.named("signReleasePublication")) } - tasks.named("publishReleasePublicationToSonatypeRepository").configure { - dependsOn tasks.named("signReleasePublication") - dependsOn tasks.named("signRcPublication") + tasks.named("publishReleasePublicationToSonatypeRepository") { + dependsOn(tasks.named("signReleasePublication")) + dependsOn(tasks.named("signRcPublication")) } } diff --git a/build.gradle b/build.gradle index 6967d7a..21619ce 100644 --- a/build.gradle +++ b/build.gradle @@ -31,11 +31,11 @@ allprojects { google() mavenCentral() maven { - url "${getLayout().getBuildDirectory()}/VCL" + url "${layout.buildDirectory.get()}/VCL" } } } tasks.register('clean', Delete) { - delete rootProject.getLayout().getBuildDirectory() + delete rootProject.layout.buildDirectory.get() } diff --git a/publish-core.gradle b/publish-core.gradle index 088263b..9a084fe 100644 --- a/publish-core.gradle +++ b/publish-core.gradle @@ -1,45 +1,35 @@ def propertiesFilePath = '/Volumes/Keybase/team/velocitycareers/mobile/android/maven/nexus.properties' -def propertiesFilePath_alternative = 'nexus.properties' +def propertiesFilePathAlternative = 'nexus.properties' -def propertiesFile = new File(propertiesFilePath) -def propertiesFile_alternative = new File(propertiesFilePath_alternative) +static def loadProperties(filePath) { + def properties = new Properties() + def file = new File(filePath) + if (file.exists()) { + file.withInputStream { stream -> + properties.load(stream) + } + } + return properties +} -def properties = new Properties() +def properties = loadProperties(propertiesFilePath) +if (properties.isEmpty()) { + properties = loadProperties(propertiesFilePathAlternative) +} -if (propertiesFile.exists()) { - try { - properties.load(new FileInputStream(propertiesFile)) - } catch (IOException e) { - e.printStackTrace() - } -} else if (propertiesFile_alternative.exists()) { - try { - properties.load(new FileInputStream(propertiesFile_alternative)) - } catch (IOException e) { - e.printStackTrace() - } -} else { - println "Properties file not found: $propertiesFilePath or $propertiesFilePath_alternative" +if (properties.isEmpty()) { + println "Properties file not found: $propertiesFilePath or $propertiesFilePathAlternative" } ext { - signingKeyId = (System.getenv("ANDROID_NEXUS_SIGNING_KEY_ID") ?: properties["signingKeyId"]) ?: println("signingKeyId was NOT found") - signingPassword = (System.getenv("ANDROID_NEXUS_SIGNING_PASSWORD") ?: properties["signingPassword"]) ?: println("signingPassword was NOT found") -// ossrhUsername = (System.getenv("ANDROID_NEXUS_OSSRH_USERNAME") ?: properties["ossrhUsername"]) ?: println("ossrhUsername was NOT found") -// ossrhPassword = (System.getenv("ANDROID_NEXUS_OSSRH_PASSWORD") ?: properties["ossrhPassword"]) ?: println("ossrhPassword was NOT found") - ossrhTokenUsername = (System.getenv("ANDROID_NEXUS_OSSRH_TOKEN_USERNAME") ?: properties["ossrhTokenUsername"]) ?: println("ossrhTokenUsername was NOT found") - ossrhTokenPassword = (System.getenv("ANDROID_NEXUS_OSSRH_TOKEN_PASSWORD") ?: properties["ossrhTokenPassword"]) ?: println("ossrhTokenPassword was NOT found") - sonatypeStagingProfileId = (System.getenv("ANDROID_NEXUS_STAGING_PROFILE_ID") ?: properties["stagingProfileId"]) ?: println("stagingProfileId was NOT found") - signingPrivateKey = (System.getenv("ANDROID_NEXUS_PRIVATE_KEY") ?: properties["signingPrivateKey"]) ?: println("signingPrivateKey was NOT found") + signingKeyId = System.getenv("ANDROID_NEXUS_SIGNING_KEY_ID") ?: properties.getProperty("signingKeyId") ?: println("signingKeyId was NOT found") + signingPassword = System.getenv("ANDROID_NEXUS_SIGNING_PASSWORD") ?: properties.getProperty("signingPassword") ?: println("signingPassword was NOT found") + ossrhTokenUsername = System.getenv("ANDROID_NEXUS_OSSRH_TOKEN_USERNAME") ?: properties.getProperty("ossrhTokenUsername") ?: println("ossrhTokenUsername was NOT found") + ossrhTokenPassword = System.getenv("ANDROID_NEXUS_OSSRH_TOKEN_PASSWORD") ?: properties.getProperty("ossrhTokenPassword") ?: println("ossrhTokenPassword was NOT found") + sonatypeStagingProfileId = System.getenv("ANDROID_NEXUS_STAGING_PROFILE_ID") ?: properties.getProperty("stagingProfileId") ?: println("stagingProfileId was NOT found") + signingPrivateKey = System.getenv("ANDROID_NEXUS_PRIVATE_KEY") ?: properties.getProperty("signingPrivateKey") ?: println("signingPrivateKey was NOT found") } -// println("signingKeyId: ${signingKeyId}") -// println("signingPassword: ${signingPassword}") -// -// println("ossrhPassword: ${ossrhPassword}") -// println("sonatypeStagingProfileId: ${sonatypeStagingProfileId}") -// println("signingPrivateKey: ${signingPrivateKey}") - nexusPublishing { repositories { sonatype { @@ -52,6 +42,10 @@ nexusPublishing { } } -// Create custom tasks for publishing -tasks.register('publishRelease') { dependsOn([':VCL:publishReleasePublicationToSonatypeRepository']) } -tasks.register('publishRc') { dependsOn([':VCL:publishRcPublicationToSonatypeRepository']) } \ No newline at end of file +tasks.register('publishRelease') { + dependsOn(':VCL:publishReleasePublicationToSonatypeRepository') +} + +tasks.register('publishRc') { + dependsOn(':VCL:publishRcPublicationToSonatypeRepository') +} \ No newline at end of file