diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index ce596d61..13e51309 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -9,7 +9,7 @@ on: workflow_dispatch: jobs: - publish: + publish-github: if: | github.event_name == 'workflow_dispatch' || ( @@ -29,6 +29,36 @@ jobs: URL: ${{ vars.REES_REPO_URL }} MAVEN_REPOSITORY_URL: ${{ vars.REES_MAVEN_URL }} GRADLE_VERSION: 8.8 + GRADLE_TASK: publishToGitHubPackages + secrets: + appSecret: ${{ secrets.PUBLISHER_SECRET }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY_FILE_AS_BASE64_STRING: ${{ secrets.SIGNING_KEY_FILE_AS_BASE64_STRING }} + + publish-maven-central: + if: false # Temporarily disabled + # if: | + # github.event_name == 'workflow_dispatch' || + # ( + # github.event_name == 'pull_request' && + # github.event.pull_request.merged == true && + # startsWith(github.event.pull_request.head.ref, 'release/') + # ) + uses: rees46/workflow/.github/workflows/reusable-android-publish.yaml@master + permissions: write-all + with: + appId: ${{ vars.PUBLISHER_ID }} + PROPERTIES_FILE: gradle.properties + SIGNING_SECRET_KEY_RING_FILE: com.rees46.key.gpg + SIGNING_SECRET_KEY_RING_FILE_LOCATION: ./personalization-sdk + OSSRH_USERNAME: ${{ vars.OSSRH_USERNAME }} + VARIANT_NAME: ${{ vars.REES_VARIANT_NAME }} + URL: ${{ vars.REES_REPO_URL }} + MAVEN_REPOSITORY_URL: ${{ vars.REES_MAVEN_URL }} + GRADLE_VERSION: 8.8 + GRADLE_TASK: publishToMavenCentral secrets: appSecret: ${{ secrets.PUBLISHER_SECRET }} SONATA_STAGING_PROFILE_ID: ${{ secrets.SONATA_STAGING_PROFILE_ID }} diff --git a/gradle/publishing/github.gradle b/gradle/publishing/github.gradle index e748c004..bb2a721c 100644 --- a/gradle/publishing/github.gradle +++ b/gradle/publishing/github.gradle @@ -1,3 +1,4 @@ +if (project.hasProperty('github')) { publishing { repositories { maven { @@ -13,3 +14,4 @@ publishing { } } } +} diff --git a/gradle/publishing/maven.gradle b/gradle/publishing/maven.gradle index 4cd55cbd..22063df4 100644 --- a/gradle/publishing/maven.gradle +++ b/gradle/publishing/maven.gradle @@ -5,7 +5,7 @@ publishing { mavenLocal() println "Publishing to local maven repository (mavenLocal) due to flag isPublishingInMavenLocal=true" } else { - println "Publishing to local maven repository" + println "Publishing to Maven Central via OSSRH Staging API Service" } maven { @@ -13,8 +13,9 @@ publishing { def repositoryId = System.getenv("SONATYPE_REPOSITORY_ID") ?: error("Missing env variable: SONATYPE_REPOSITORY_ID") - def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" - def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deployByRepositoryId/${repositoryId}/" + // Updated URLs for OSSRH Staging API Service (compatibility layer) + def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/" + def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deployByRepositoryId/${repositoryId}/" url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl println "Configured Sonatype repository with URL: ${url}" @@ -35,8 +36,9 @@ nexusPublishing { stagingProfileId = project.findProperty("stagingProfileId") ?: "" username = sonataUsername password = sonataPassword - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + // Updated URLs for OSSRH Staging API Service (compatibility layer) + nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/")) } } } diff --git a/personalization-sdk/build.gradle b/personalization-sdk/build.gradle index cc291585..249a9352 100644 --- a/personalization-sdk/build.gradle +++ b/personalization-sdk/build.gradle @@ -175,3 +175,24 @@ tasks.register("printVariants") { } } } + +// Custom publishing tasks for independent repository publishing +tasks.register('publishToGitHubPackages') { + group = 'publishing' + description = 'Publish to GitHub Packages only' + dependsOn 'publish' + doFirst { + project.ext.set('github', true) + println "Publishing to GitHub Packages only" + } +} + +tasks.register('publishToMavenCentral') { + group = 'publishing' + description = 'Publish to Maven Central only' + dependsOn 'publish' + doFirst { + project.ext.set('sonatype', true) + println "Publishing to Maven Central only" + } +}