Skip to content

Commit

Permalink
ci: setup github actions to verify and release
Browse files Browse the repository at this point in the history
  • Loading branch information
goatfryed committed Sep 10, 2024
1 parent 63a7833 commit 8d86b6d
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Publish package to the Maven Central Repository
on:
release:
types: [published]
jobs:
publish-release:
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- uses: gradle/actions/setup-gradle@v4
- name: Publish
run: ./gradlew publish
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingPrivateKey: ${{ secrets.GPG_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGING_PASSPHRASE }}
20 changes: 20 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish package to the Maven Central Repository
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
publish-release:
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: Verify
run: ./gradlew check
21 changes: 17 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
id 'maven-publish'
id 'signing'
}

group = "io.github.goatfryed"
Expand Down Expand Up @@ -91,7 +92,7 @@ tasks.named('javadoc', Javadoc) {

publishing {
publications {
mavenJava(MavenPublication) {
lib(MavenPublication) {
from components.java

pom {
Expand All @@ -113,16 +114,28 @@ publishing {
email = 'goatfryed@gmail.com'
}
}

scm {
connection = 'scm:git:git://github.com/goatfryed/assert-baseline.git'
developerConnection = 'scm:git:ssh://github.com/goatfryed/assert-baseline.git'
url = 'github.com/goatfryed/assert-baseline'
}
}
}
}

repositories {
maven {
name = 'MavenCentral'
url = version.endsWith('SNAPSHOT') ?
uri('https://s01.oss.sonatype.org/content/repositories/snapshots/') :
uri('https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/')
url = uri('https://central.sonatype.com/api/v1/publisher')
credentials(org.gradle.api.credentials.PasswordCredentials)
}
}
}

signing {
def signingKey = findProject("signing.privateKey")
def signingPassword = findProject("signing.password")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications
}
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@
org.gradle.parallel=true
org.gradle.caching=true

signingPrivateKey=
signingPassword=
mavenCentralUsername=
mavenCentralPassword=

0 comments on commit 8d86b6d

Please sign in to comment.