Skip to content

Commit

Permalink
Enable publishing to maven central (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
dellisd authored Jul 12, 2023
1 parent b610363 commit 3737ced
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 25 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish a release

on:
push:
branches: [ main ]
tags: [ '*' ]

jobs:
publish:
runs-on: ubuntu-latest

if: github.repository == 'cashapp/better-dynamic-features'
permissions:
contents: read

steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1
- uses: actions/[email protected]
with:
distribution: 'zulu'
java-version: 17

- name: Publish Artifacts
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
run: ./gradlew publishAllPublicationsToMavenCentralRepository

env:
GRADLE_OPTS: -Dorg.gradle.parallel=true -Dorg.gradle.caching=true
28 changes: 27 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.publish) apply false
alias(libs.plugins.publish)
alias(libs.plugins.spotless)
alias(libs.plugins.wire) apply false
}
Expand All @@ -22,3 +22,29 @@ spotless {
licenseHeaderFile(rootProject.file('gradle/license-header.txt'))
}
}

subprojects {
plugins.withId("com.vanniktech.maven.publish") {
publishing {
repositories {
maven {
name = "installLocally"
url = "${rootProject.buildDir}/localMaven"
}
/**
* Want to push to an internal repository for testing?
* Set the following properties in ~/.gradle/gradle.properties.
*
* internalUrl=YOUR_INTERNAL_URL
* internalUsername=YOUR_USERNAME
* internalPassword=YOUR_PASSWORD
*/
maven {
name = "internal"
url = providers.gradleProperty("internalUrl")
credentials(PasswordCredentials)
}
}
}
}
}
22 changes: 0 additions & 22 deletions gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,6 @@ dependencies {
testImplementation(libs.truth)
}

publishing {
repositories {
maven {
name = "installLocally"
url = "${rootProject.buildDir}/localMaven"
}
/**
* Want to push to an internal repository for testing?
* Set the following properties in ~/.gradle/gradle.properties.
*
* internalUrl=YOUR_INTERNAL_URL
* internalUsername=YOUR_USERNAME
* internalPassword=YOUR_PASSWORD
*/
maven {
name = "internal"
url = providers.gradleProperty("internalUrl")
credentials(PasswordCredentials)
}
}
}

def pluginVersion = tasks.register("pluginVersion") {
def outputDir = file("$buildDir/gen")

Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=app.cash.better.dynamic.features
VERSION_NAME=0.1.0-alpha32
VERSION_NAME=0.1.0-SNAPSHOT

POM_URL=https://github.com/cashapp/better-dynamic-features/
POM_SCM_URL=https://github.com/cashapp/better-dynamic-features/
Expand All @@ -13,6 +13,7 @@ POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=square
POM_DEVELOPER_NAME=Square, Inc.

RELEASE_SIGNING_ENABLED=false
SONATYPE_HOST=DEFAULT
RELEASE_SIGNING_ENABLED=true

android.useAndroidX=true

0 comments on commit 3737ced

Please sign in to comment.