diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0d4b51b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,40 @@ +name: Publish + +on: + release: + # Run this workflow when a new GitHub release is created + types: [released] + +jobs: + publish: + name: Release build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3.1.0 + with: + ref: release + - name: Set up JDK 11 + uses: actions/setup-java@v3.6.0 + with: + distribution: adopt + java-version: 11 + + # Builds the release artifacts + - name: Release build + run: ./gradlew :format-watcher:assembleRelease + + # Generates artifacts androidSourcesJar and javadocJar + - name: Source jar and dokka + run: ./gradlew androidSourcesJar javadocJar + + - name: Publish to MavenCentral + run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository + + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} diff --git a/gradle/publish-root.gradle b/gradle/publish-root.gradle index 00d8122..93a9fcf 100644 --- a/gradle/publish-root.gradle +++ b/gradle/publish-root.gradle @@ -13,7 +13,7 @@ if (secretPropsFile.exists()) { new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } p.each { name, value -> ext[name] = value } } else { - // Use system environment variables + // System environment variables ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') @@ -28,6 +28,9 @@ nexusPublishing { sonatype { nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + stagingProfileId = sonatypeStagingProfileId + username = ossrhUsername + password = ossrhPassword } } } \ No newline at end of file