Skip to content

Commit

Permalink
Enable automatic nexus publishing (#744)
Browse files Browse the repository at this point in the history
* chore: use gradle-nexus plugin for automatic artifact publishing

* refactor: move gradle task updateAsyncApiJson to other tasks

* docs: update RELEASING.md

* chore(gh): automatically publish nexus release in release pipeline
  • Loading branch information
timonback authored May 24, 2024
1 parent 1d8afdc commit e153c47
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 37 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/publish-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ jobs:
ORG_GRADLE_PROJECT_DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Publish maven artifacts
run: ./gradlew publish
run: ./gradlew publish closeAndReleaseStagingRepositories
env:
ORG_GRADLE_PROJECT_SIGNINGKEY: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGKEY}}
ORG_GRADLE_PROJECT_SIGNINGPASSWORD: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD}}
ORG_GRADLE_PROJECT_MAVEN_URL: https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
ORG_GRADLE_PROJECT_MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/springwolf-addons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ jobs:
ORG_GRADLE_PROJECT_SIGNINGKEY: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGKEY}}
ORG_GRADLE_PROJECT_SIGNINGPASSWORD: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD}}

ORG_GRADLE_PROJECT_MAVEN_URL: https://s01.oss.sonatype.org/content/repositories/snapshots/
ORG_GRADLE_PROJECT_MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
1 change: 0 additions & 1 deletion .github/workflows/springwolf-asyncapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ jobs:
ORG_GRADLE_PROJECT_SIGNINGKEY: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGKEY}}
ORG_GRADLE_PROJECT_SIGNINGPASSWORD: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD}}

ORG_GRADLE_PROJECT_MAVEN_URL: https://s01.oss.sonatype.org/content/repositories/snapshots/
ORG_GRADLE_PROJECT_MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
1 change: 0 additions & 1 deletion .github/workflows/springwolf-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ jobs:
ORG_GRADLE_PROJECT_SIGNINGKEY: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGKEY}}
ORG_GRADLE_PROJECT_SIGNINGPASSWORD: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD}}

ORG_GRADLE_PROJECT_MAVEN_URL: https://s01.oss.sonatype.org/content/repositories/snapshots/
ORG_GRADLE_PROJECT_MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
1 change: 0 additions & 1 deletion .github/workflows/springwolf-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ jobs:
ORG_GRADLE_PROJECT_SIGNINGKEY: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGKEY}}
ORG_GRADLE_PROJECT_SIGNINGPASSWORD: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD}}

ORG_GRADLE_PROJECT_MAVEN_URL: https://s01.oss.sonatype.org/content/repositories/snapshots/
ORG_GRADLE_PROJECT_MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
1 change: 0 additions & 1 deletion .github/workflows/springwolf-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,5 @@ jobs:
ORG_GRADLE_PROJECT_SIGNINGKEY: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGKEY}}
ORG_GRADLE_PROJECT_SIGNINGPASSWORD: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD}}

ORG_GRADLE_PROJECT_MAVEN_URL: https://s01.oss.sonatype.org/content/repositories/snapshots/
ORG_GRADLE_PROJECT_MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
1 change: 0 additions & 1 deletion .github/workflows/springwolf-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
ORG_GRADLE_PROJECT_SIGNINGKEY: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGKEY}}
ORG_GRADLE_PROJECT_SIGNINGPASSWORD: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD}}

ORG_GRADLE_PROJECT_MAVEN_URL: https://s01.oss.sonatype.org/content/repositories/snapshots/
ORG_GRADLE_PROJECT_MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
ORG_GRADLE_PROJECT_MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}

Expand Down
8 changes: 2 additions & 6 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,5 @@ The following list describe the steps necessary to release a new version.
3. Update `all-contributors` in [README.md](README.md)
4. Remove the `-SNAPHSOT` postfix in `.env`, create a new branch `release/0.X.X` (version number), commit & push
5. Run GitHub `Publish releases` pipeline from the newly created release branch
1. The stage artifacts can be viewed in https://s01.oss.sonatype.org/#view-repositories
2. To view them, select `Nexus Managed Repositories` in the drop-down and search for springwolf in the searchbox
6. Release version in nexus
1. Artifacts are visible in the public maven repository: https://repo1.maven.org/maven2/io/github/springwolf/
7. Update version number on website
8. Update the version number in `.env` for next snapshot on branch `master`, commit & push
6. Update version number on website
7. Update the version number in `.env` for next snapshot on branch `master`, commit & push
45 changes: 22 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ buildscript {
}

plugins {
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
id 'ca.cutterslade.analyze' version '1.9.1'
id 'io.spring.dependency-management' version '1.1.5' apply false
id 'org.springframework.boot' version '3.2.5' apply false
Expand Down Expand Up @@ -91,7 +92,6 @@ allprojects {
exceptionFormat = 'full'
}
}

tasks.register('unitTest', Test) {
enabled = !it.project.name.contains("-example") // Examples do not contain unit tests and would fail otherwise
dependsOn spotlessApply // Automatically fix code formatting if possible
Expand All @@ -110,8 +110,6 @@ allprojects {
exceptionFormat = 'full'
}
}


tasks.register('integrationTest', Test) {
dependsOn spotlessApply // Automatically fix code formatting if possible

Expand All @@ -130,6 +128,19 @@ allprojects {
}
}

tasks.register('updateAsyncApiJson') {
group 'verification'
description 'Update the AsyncAPI JSON files in the examples to match the current state of the plugin'

doLast { // ensure that the code is not executed as part of a gradle refresh
plugins.forEach {
project
.file('springwolf-examples/' + it + '-example/src/test/resources/asyncapi.actual.json')
.renameTo('springwolf-examples/' + it + '-example/src/test/resources/asyncapi.json')
}
}
}

var addons = [
'springwolf-common-model-converters' ,
'springwolf-generic-binding' ,
Expand Down Expand Up @@ -215,16 +226,6 @@ allprojects {
}
}
}

repositories {
maven {
url = project.findProperty('MAVEN_URL')
credentials {
username = project.findProperty('MAVEN_USERNAME') ?: ''
password = project.findProperty('MAVEN_PASSWORD') ?: ''
}
}
}
}

signing {
Expand All @@ -234,17 +235,15 @@ allprojects {
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
}

tasks.register('updateAsyncApiJson') {
group 'verification'
description 'Update the AsyncAPI JSON files in the examples to match the current state of the plugin'

doLast { // ensure that the code is not executed as part of a gradle refresh
plugins.forEach {
project
.file('springwolf-examples/' + it + '-example/src/test/resources/asyncapi.actual.json')
.renameTo('springwolf-examples/' + it + '-example/src/test/resources/asyncapi.json')
}
nexusPublishing {
repositories {
MavenRepository {
nexusUrl = uri('https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/')
snapshotRepositoryUrl = uri('https://s01.oss.sonatype.org/content/repositories/snapshots/')
username = project.findProperty('MAVEN_USERNAME') ?: ''
password = project.findProperty('MAVEN_PASSWORD') ?: ''
}
}
}
Expand Down

0 comments on commit e153c47

Please sign in to comment.