diff --git a/.github/workflows/publish.yml b/.github/workflows/main.yml similarity index 71% rename from .github/workflows/publish.yml rename to .github/workflows/main.yml index 4d81a0a..eaa0559 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Publish +name: Main Branch on: # Runs on pushes targeting the default branch @@ -14,7 +14,7 @@ permissions: # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: - group: "publish" + group: "main" cancel-in-progress: false jobs: @@ -31,17 +31,18 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: '21' + java-version: '17' check-latest: true - name: Gradle Wrapper Validation uses: gradle/actions/wrapper-validation@v3 + - name: Test on Ubuntu run: ./gradlew assemble check --no-build-cache --no-daemon --stacktrace # Deploy to Github Pages - deploy: + github-pages: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} @@ -93,21 +94,51 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'zulu' - java-version: '21' + java-version: '17' check-latest: true - name: Gradle Wrapper Validation uses: gradle/actions/wrapper-validation@v3 + - name: Retrieve Version from gradle.properties + run: echo "VERSION_NAME=$(cat gradle.properties | grep "^version=" | awk -F'=' '{print $2}')" >> $GITHUB_ENV + - name: Publish Snapshot run: ./gradlew :invert-models:publish :invert-gradle-plugin:publish --no-configuration-cache --stacktrace + if: success() && endsWith(env.VERSION_NAME, '-SNAPSHOT') env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} + + publish-release: + needs: + - test-ubuntu + runs-on: ubuntu-latest + if: github.repository == 'square/invert' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + timeout-minutes: 25 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '17' + check-latest: true + + - name: Gradle Wrapper Validation + uses: gradle/actions/wrapper-validation@v3 + + - name: Retrieve Version from gradle.properties + run: echo "VERSION_NAME=$(cat gradle.properties | grep "^version=" | awk -F'=' '{print $2}')" >> $GITHUB_ENV + - name: Publish release (main only) - run: ./gradlew :invert-models:closeAndReleaseRepository :invert-gradle-plugin:closeAndReleaseRepository --no-configuration-cache --stacktrace + run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache --stacktrace if: success() && !endsWith(env.VERSION_NAME, '-SNAPSHOT') 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 }} diff --git a/.github/workflows/checks.yml b/.github/workflows/pr-checks.yml similarity index 91% rename from .github/workflows/checks.yml rename to .github/workflows/pr-checks.yml index 16d5149..e71ae71 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/pr-checks.yml @@ -1,9 +1,7 @@ name: Checks on: - # Runs on pushes targeting the default branch - push: - branches: ["main"] + # Runs on PRs targeting the default branch pull_request: branches: ["main"] diff --git a/build.gradle.kts b/build.gradle.kts index fff66c1..d61e992 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,9 @@ buildscript { mavenCentral() google() gradlePluginPortal() - maven { url = uri("https://oss.sonatype.org/service/local/repositories/snapshots/content") } // SNAPSHOT Versions for statik + maven { + url = uri("https://oss.sonatype.org/service/local/repositories/snapshots/content") + } // SNAPSHOT Versions for statik } } @@ -16,7 +18,9 @@ allprojects { mavenCentral() google() gradlePluginPortal() - maven { url = uri("https://oss.sonatype.org/service/local/repositories/snapshots/content") } // SNAPSHOT Versions for statik + maven { + url = uri("https://oss.sonatype.org/service/local/repositories/snapshots/content") + } // SNAPSHOT Versions for statik } } @@ -39,14 +43,10 @@ subprojects it.afterEvaluate { val hasPublishPlugin = it.plugins.hasPlugin("com.vanniktech.maven.publish.base") if (hasPublishPlugin) { - val extension = it.extensions.getByType(MavenPublishBaseExtension::class.java) - extension.apply { - // publishToMavenCentral(SonatypeHost.DEFAULT) - // or when publishing to https://s01.oss.sonatype.org + it.extensions.getByType(MavenPublishBaseExtension::class.java).apply { publishToMavenCentral(SonatypeHost.S01, automaticRelease = true) - // or when publishing to https://central.sonatype.com/ signAllPublications() } } } - } \ No newline at end of file + } diff --git a/collectors/collectors-anvil-dagger/build.gradle.kts b/collectors/collectors-anvil-dagger/build.gradle.kts index 37a684a..4db7d2f 100644 --- a/collectors/collectors-anvil-dagger/build.gradle.kts +++ b/collectors/collectors-anvil-dagger/build.gradle.kts @@ -2,7 +2,7 @@ plugins { kotlin("jvm") id("java-gradle-plugin") kotlin("plugin.serialization") - alias(libs.plugins.vanniktech.maven.publish) +// alias(libs.plugins.vanniktech.maven.publish) } java { diff --git a/collectors/collectors-kotlin-java-loc/build.gradle.kts b/collectors/collectors-kotlin-java-loc/build.gradle.kts index e119ad3..482bb4e 100644 --- a/collectors/collectors-kotlin-java-loc/build.gradle.kts +++ b/collectors/collectors-kotlin-java-loc/build.gradle.kts @@ -2,7 +2,7 @@ plugins { kotlin("jvm") id("java-gradle-plugin") kotlin("plugin.serialization") - alias(libs.plugins.vanniktech.maven.publish) +// alias(libs.plugins.vanniktech.maven.publish) } java { diff --git a/gradle.properties b/gradle.properties index 70ccd57..5262e25 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ kotlin.code.style=official android.useAndroidX=true group=com.squareup.invert -version=0.0.1-dev-SNAPSHOT +version=0.0.1-dev diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9db3a2e..dc48d91 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ javax-inject = "1" kotlin = "2.0.0" kotlinx-serialization = "1.6.3" ktor = "2.3.11" -vanniktech-maven-publish = "0.28.0" +vanniktech-maven-publish = "0.29.0" jetbrains-compose = "1.6.10" ksp = "1.9.23-1.0.20" truth = "1.4.2" diff --git a/invert-gradle-plugin/build.gradle.kts b/invert-gradle-plugin/build.gradle.kts index 76cd785..95d9c7a 100644 --- a/invert-gradle-plugin/build.gradle.kts +++ b/invert-gradle-plugin/build.gradle.kts @@ -1,3 +1,7 @@ +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import com.vanniktech.maven.publish.KotlinJvm +import com.vanniktech.maven.publish.JavadocJar + plugins { kotlin("jvm") kotlin("plugin.serialization") @@ -5,6 +9,16 @@ plugins { alias(libs.plugins.vanniktech.maven.publish) } +project.extensions.getByType(MavenPublishBaseExtension::class.java).apply { + configure( + KotlinJvm( + javadocJar = JavadocJar.None(), + // whether to publish a sources jar + sourcesJar = true, + ) + ) +} + gradlePlugin { plugins { this.create("invertPlugin").apply { @@ -43,4 +57,8 @@ tasks { named("processResources") { duplicatesStrategy = DuplicatesStrategy.INCLUDE } -} \ No newline at end of file +} + +tasks.named("publishMavenPublicationToMavenCentralRepository") { + mustRunAfter("signPluginMavenPublication") +} diff --git a/invert-models/build.gradle.kts b/invert-models/build.gradle.kts index d11c5c1..ff4e4b1 100644 --- a/invert-models/build.gradle.kts +++ b/invert-models/build.gradle.kts @@ -1,4 +1,6 @@ -import com.vanniktech.maven.publish.SonatypeHost +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import com.vanniktech.maven.publish.KotlinMultiplatform +import com.vanniktech.maven.publish.JavadocJar plugins { kotlin("multiplatform") @@ -6,6 +8,16 @@ plugins { alias(libs.plugins.vanniktech.maven.publish) } +project.extensions.getByType(MavenPublishBaseExtension::class.java).apply { + configure( + KotlinMultiplatform( + javadocJar = JavadocJar.None(), + // whether to publish a sources jar + sourcesJar = true, + ) + ) +} + kotlin { js { browser() diff --git a/owners/owners-github-codeowners/build.gradle.kts b/owners/owners-github-codeowners/build.gradle.kts index 09cabb8..d3746ae 100644 --- a/owners/owners-github-codeowners/build.gradle.kts +++ b/owners/owners-github-codeowners/build.gradle.kts @@ -1,7 +1,7 @@ plugins { kotlin("jvm") id("java-gradle-plugin") - alias(libs.plugins.vanniktech.maven.publish) +// alias(libs.plugins.vanniktech.maven.publish) } dependencies {