diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 3effefe..f25414d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,7 +1,6 @@ name: Build on: - workflow_dispatch: pull_request: branches: - '*' diff --git a/.github/workflows/publish-release.yaml b/.github/workflows/publish-release.yaml new file mode 100644 index 0000000..0f6223c --- /dev/null +++ b/.github/workflows/publish-release.yaml @@ -0,0 +1,33 @@ +name: Publish Release + +on: + release: + types: [ published ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '8.0.x' + - name: Set up GPG + run: echo -n "${GPG_PRIVATE_KEY}" | base64 --decode > ${GITHUB_WORKSPACE}/${GPG_KEY_ID}.gpg + env: + GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + - name: "Gradle Build" + run: ./gradlew build -Pversion=${GITHUB_REF:10} + - name: "Gradle Publish" + run: | + ./gradlew publishToSonatype -Pversion=${GITHUB_REF:10} \ + -Psigning.keyId=${GPG_KEY_ID} \ + -Psigning.password=${GPG_PASSPHRASE} \ + -Psigning.secretKeyRingFile=${GITHUB_WORKSPACE}/${GPG_KEY_ID}.gpg + env: + ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.OSSRH_PASSWORD }} + GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} diff --git a/build.gradle.kts b/build.gradle.kts index 6d3c680..f5959a4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,6 +21,7 @@ plugins { `maven-publish` id("ru.vyarus.quality") version "4.9.0" id("io.spring.dependency-management") version "1.1.0" + id("io.github.gradle-nexus.publish-plugin") version "1.3.0" } configure(listOf(rootProject)) { @@ -28,6 +29,12 @@ configure(listOf(rootProject)) { group = "io.qameta.atlas" } +nexusPublishing { + repositories { + sonatype() + } +} + configure(subprojects) { group = "io.qameta.atlas" version = version @@ -42,29 +49,21 @@ configure(subprojects) { java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 + + withJavadocJar() + withSourcesJar() } tasks.compileJava { options.encoding = "UTF-8" } - val sourceJar by tasks.creating(Jar::class) { - from(sourceSets.getByName("main").allSource) - archiveClassifier.set("sources") - } - - val javadocJar by tasks.creating(Jar::class) { - from(tasks.getByName("javadoc")) - archiveClassifier.set("javadoc") - } - tasks.withType(Javadoc::class) { - (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet") + (options as StandardJavadocDocletOptions).apply { + addStringOption("Xdoclint:none", "-quiet") + } } - artifacts.add("archives", sourceJar) - artifacts.add("archives", javadocJar) - configure { dependencies { dependency("org.apache.commons:commons-lang3:3.12.0") @@ -85,8 +84,56 @@ configure(subprojects) { } } + publishing { + publications { + create("maven") { + suppressAllPomMetadataWarnings() + versionMapping { + allVariants { + fromResolutionResult() + } + } + pom { + name.set(project.name) + description.set("Module ${project.name} of Atlas.") + url.set("https://github.com/qameta/atlas") + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + developers { + developer { + id.set("eroshenkoam") + name.set("Artem Eroshenko") + email.set("artem.eroshenko@qameta.io") + } + } + scm { + developerConnection.set("scm:git:git://github.com/qameta/atlas") + connection.set("scm:git:git://github.com/qameta/atlas") + url.set("https://github.com/qameta/atlas") + } + issueManagement { + system.set("GitHub Issues") + url.set("https://github.com/qameta/atlas/issues") + } + } + } + } + } + + signing { + sign(publishing.publications["maven"]) + } + + tasks.withType().configureEach { + onlyIf { !project.version.toString().endsWith("-SNAPSHOT") } + } + repositories { - jcenter() mavenLocal() + mavenCentral() } }