Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: publish

on:
push:
branches: [ "main" ]

jobs:
unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: unit-test
run: ./gradlew test

release:
needs: [ unit ]
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.nextStrict }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true

- id: version
uses: ietf-tools/semver-action@v1.9.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: main
majorList: feat!
minorList: feat, feature
patchList: fix, bugfix
noVersionBumpBehavior: patch
noNewCommitBehavior: silent

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.version.outputs.nextStrict }}" --target "${{ github.sha }}"

- name: Tag Release
env:
TAG: ${{ steps.version.outputs.nextStrict }}
run: |
git tag ${TAG} ${GITHUB_SHA}
git push origin ${TAG}

- name: Publish package to Maven Central
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USER }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_PUBLIC_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSPHRASE }}
COMMONS_RELEASE_VERSION: ${{ steps.version.outputs.nextStrict }}
run: |
./gradlew publishToMavenCentral
79 changes: 36 additions & 43 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
`java-library`
`maven-publish`
id("com.diffplug.spotless") version "6.23.3"
id("com.vanniktech.maven.publish.base") version "0.34.0"
}

group = "org.mitre"
Expand Down Expand Up @@ -66,50 +66,43 @@ spotless {
}
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = "commons"
from(components["java"])
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
pom {
name.set(project.name)
description.set("MITRE Commons Library for Aviation")
url.set("https://github.com/mitre-public/commons")
mavenPublishing {
publishToMavenCentral(automaticRelease = false)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll flip this to true after the first release looks good.

signAllPublications()

val releaseVersion = System.getenv("COMMONS_RELEASE_VERSION")
version = if (releaseVersion.isNullOrBlank()) project.version.toString() else releaseVersion

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("jparker")
name.set("Jon Parker")
email.set("jiparker@mitre.org")
}
developer {
id.set("dbaker")
name.set("David Baker")
email.set("dbaker@mitre.org")
}
}
coordinates("org.mitre", project.name, version.toString())

//REQUIRED! To publish to maven central (from experience the leading "scm:git" is required too)
scm {
connection.set("scm:git:https://github.com/mitre-public/commons.git")
developerConnection.set("scm:git:ssh://git@github.com:mitre-public/commons.git")
url.set("https://github.com/mitre-public/commons")
}
pom {
name.set(project.name)
description.set("MITRE Commons Library for Aviation")
inceptionYear.set("2023")
url.set("https://github.com/mitre-public/commons")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("dbaker-mitre")
name.set("David Baker")
url.set("https://github.com/dbaker-mitre")
}
developer {
id.set("mattpollock")
name.set("Matt Pollock")
url.set("https://github.com/mattpollock")
}
}
scm {
url.set("https://github.com/mitre-public/commons")
connection.set("scm:git:https://github.com/mitre-public/commons.git")
developerConnection.set("scm:git:ssh://git@github.com:mitre-public/commons.git")
}
}
}
}
Loading