Skip to content

Commit

Permalink
add release workflow (via #110)
Browse files Browse the repository at this point in the history
  • Loading branch information
eroshenkoam authored Apr 18, 2023
1 parent ddec29f commit 8c7a2ad
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 16 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Build

on:
workflow_dispatch:
pull_request:
branches:
- '*'
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/publish-release.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
77 changes: 62 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@ 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)) {
description = "Atlas"
group = "io.qameta.atlas"
}

nexusPublishing {
repositories {
sonatype()
}
}

configure(subprojects) {
group = "io.qameta.atlas"
version = version
Expand All @@ -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<DependencyManagementExtension> {
dependencies {
dependency("org.apache.commons:commons-lang3:3.12.0")
Expand All @@ -85,8 +84,56 @@ configure(subprojects) {
}
}

publishing {
publications {
create<MavenPublication>("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<Sign>().configureEach {
onlyIf { !project.version.toString().endsWith("-SNAPSHOT") }
}

repositories {
jcenter()
mavenLocal()
mavenCentral()
}
}

0 comments on commit 8c7a2ad

Please sign in to comment.