-
Notifications
You must be signed in to change notification settings - Fork 1
Maven Central publishing, CD automation #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
72ce305
feat: add CD pipeline for Maven Central Portal publishing
halotukozak 9b50770
refactor: streamline Gradle build script and update developer metadata
halotukozak 73575ab
update developer email in pom configuration
halotukozak e28de9e
feat: integrate vanniktech maven-publish plugin and configure central…
halotukozak 37b97ac
refactor: move Maven publishing config to plugin module only
halotukozak f654f05
chore: centralize Maven publishing configuration in root project
halotukozak d8c8da2
fix: address PR review feedback from ddworak
halotukozak 17d8c3c
docs: add comprehensive README for Gradle plugin usage
halotukozak 6035a19
fix: add tag validation and CI gate to CD workflow
halotukozak 9ca1035
Merge branch 'master' into feat/cd-maven-central
halotukozak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| name: CD | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| ci: | ||
| uses: ./.github/workflows/ci.yml | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| validate-tag: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Validate semver tag | ||
| run: | | ||
| TAG="${GITHUB_REF_NAME}" | ||
| if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(.*)$ ]]; then | ||
| echo "::error::Tag '$TAG' does not match semver format (expected v<major>.<minor>.<patch>)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| publish: | ||
| needs: [ ci, validate-tag ] | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: temurin | ||
| java-version: 21 | ||
|
|
||
| - uses: gradle/actions/setup-gradle@v4 | ||
|
|
||
| - name: Publish to Maven Central | ||
| env: | ||
| RELEASE_VERSION: ${{ github.ref_name }} | ||
| ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} | ||
| ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} | ||
| ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SIGNING_KEY }} | ||
| ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_SIGNING_PASSWORD }} | ||
| run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,92 @@ | ||
| # justworks | ||
|
|
||
| A Gradle plugin that generates type-safe Kotlin [Ktor](https://ktor.io/) client code from OpenAPI 3.0 specifications. | ||
|
|
||
| ## Installation | ||
|
|
||
| Add the plugin to your `build.gradle.kts`: | ||
|
|
||
| ```kotlin | ||
| plugins { | ||
| id("com.avsystem.justworks") version "<version>" | ||
| } | ||
| ``` | ||
|
|
||
| The plugin and core library are published to Maven Central: | ||
|
|
||
| - `com.avsystem.justworks:plugin` -- Gradle plugin | ||
| - `com.avsystem.justworks:core` -- OpenAPI parser and code generator | ||
|
|
||
| ## Usage | ||
|
|
||
| Configure one or more OpenAPI specs in the `justworks` extension: | ||
|
|
||
| ```kotlin | ||
| justworks { | ||
| specs { | ||
| register("petstore") { | ||
| specFile = file("api/petstore.yaml") | ||
| packageName = "com.example.petstore" | ||
| } | ||
| register("payments") { | ||
| specFile = file("api/payments.yaml") | ||
| packageName = "com.example.payments" | ||
| // Optional: override default sub-packages | ||
| apiPackage = "com.example.payments.client" | ||
| modelPackage = "com.example.payments.dto" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Each spec gets its own Gradle task (`justworksGenerate<Name>`) and output directory. Run all generators at once with: | ||
|
|
||
| ```bash | ||
| ./gradlew justworksGenerateAll | ||
| ``` | ||
|
|
||
| Generated sources are automatically wired into Kotlin source sets, so `compileKotlin` depends on code generation -- no extra configuration needed. | ||
|
|
||
| ### Configuration options | ||
|
|
||
| | Property | Required | Default | Description | | ||
| |----------------|----------|--------------------------|--------------------------------------| | ||
| | `specFile` | Yes | -- | Path to the OpenAPI spec (.yaml/.json) | | ||
| | `packageName` | Yes | -- | Base package for generated code | | ||
| | `apiPackage` | No | `$packageName.api` | Package for API client classes | | ||
| | `modelPackage` | No | `$packageName.model` | Package for model/data classes | | ||
|
|
||
| ## Publishing | ||
|
|
||
| Releases are published to [Maven Central](https://central.sonatype.com/) automatically when a version tag (`v*`) is pushed. The CD pipeline runs CI checks first, then publishes signed artifacts via the [vanniktech maven-publish](https://github.com/vanniktech/gradle-maven-publish-plugin) plugin. | ||
|
|
||
| To trigger a release: | ||
|
|
||
| ```bash | ||
| git tag v1.0.0 | ||
| git push origin v1.0.0 | ||
| ``` | ||
|
|
||
| The version is derived from the tag (stripping the `v` prefix). Without a tag, the version defaults to `0.0.1-SNAPSHOT`. | ||
|
|
||
| ## Development | ||
|
|
||
| Requires **JDK 21+**. | ||
|
|
||
| ```bash | ||
| # Run tests and linting | ||
| ./gradlew check | ||
|
|
||
| # Run only unit tests | ||
| ./gradlew test | ||
|
|
||
| # Run functional tests (plugin module) | ||
| ./gradlew plugin:functionalTest | ||
|
|
||
| # Lint check | ||
| ./gradlew ktlintCheck | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| Apache License 2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,66 @@ | ||
| import com.vanniktech.maven.publish.MavenPublishBaseExtension | ||
| import com.vanniktech.maven.publish.SonatypeHost | ||
|
|
||
| plugins { | ||
| kotlin("jvm") version "2.3.0" apply false | ||
| id("org.jlleitschuh.gradle.ktlint") version "12.1.2" apply false | ||
| id("org.jetbrains.kotlinx.kover") version "0.9.1" apply false | ||
|
halotukozak marked this conversation as resolved.
|
||
| id("com.vanniktech.maven.publish") version "0.30.0" apply false | ||
|
halotukozak marked this conversation as resolved.
|
||
| } | ||
|
|
||
| allprojects { | ||
| group = "com.avsystem" | ||
| version = "0.0.1" | ||
| group = "com.avsystem.justworks" | ||
| version = System | ||
| .getenv("RELEASE_VERSION") | ||
|
halotukozak marked this conversation as resolved.
|
||
| ?.let { Regex("""^v(\d+\.\d+\.\d+.*)$""").matchEntire(it)?.groupValues?.get(1) } | ||
| ?: "0.0.1-SNAPSHOT" | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| } | ||
|
|
||
| apply(plugin = "org.jlleitschuh.gradle.ktlint") | ||
| } | ||
|
|
||
| subprojects { | ||
| pluginManager.withPlugin("com.vanniktech.maven.publish") { | ||
| extensions.configure<MavenPublishBaseExtension> { | ||
| publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) | ||
| signAllPublications() | ||
|
|
||
| pom { | ||
| url = "https://github.com/AVSystem/justworks" | ||
|
|
||
| licenses { | ||
| license { | ||
| name = "The Apache License, Version 2.0" | ||
| url = "https://www.apache.org/licenses/LICENSE-2.0.txt" | ||
| } | ||
| } | ||
|
|
||
| developers { | ||
| developer { | ||
| id = "halotukozak" | ||
| name = "Bartłomiej Kozak" | ||
| email = "b.kozak@avsystem.com" | ||
| organization = "AVSystem" | ||
| organizationUrl = "https://www.avsystem.com" | ||
| } | ||
| developer { | ||
| id = "mzielu" | ||
| name = "Marcin Zieliński" | ||
| email = "m.zielinski@avsystem.com" | ||
| organization = "AVSystem" | ||
| organizationUrl = "https://www.avsystem.com" | ||
| } | ||
| } | ||
|
|
||
| scm { | ||
| connection = "scm:git:git://github.com/AVSystem/justworks.git" | ||
| developerConnection = "scm:git:ssh://github.com/AVSystem/justworks.git" | ||
| url = "https://github.com/AVSystem/justworks" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.