Skip to content

Commit

Permalink
Refactor publish pipeline (#2)
Browse files Browse the repository at this point in the history
* Add missing signing config

* Create separate build step to optimize non-parallel publish

* Update repository config to enable only if parameters are present
  • Loading branch information
boswelja authored Apr 6, 2024
1 parent 15c15ac commit 48696f5
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 32 deletions.
38 changes: 26 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,25 @@ on:
workflow_dispatch:

jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build
run: ./gradlew assembleRelease --scan

publish-github:
runs-on: ubuntu-latest
runs-on: macos-latest
environment: github
needs: build
permissions:
contents: read
packages: write
Expand All @@ -20,18 +37,17 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build
run: ./gradlew publishAllPublicationsToGithubRepository --scan
run: ./gradlew publishAllPublicationsToGithubRepository --scan -Dorg.gradle.parallel=false
env:
PUBLISHING: true
ORG_GRADLE_PROJECT_githubUsername: boswelja
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}

publish-oss:
runs-on: ubuntu-latest
runs-on: macos-latest
environment: mavencentral
needs: build
permissions:
contents: read
packages: write
Expand All @@ -46,18 +62,16 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build
run: ./gradlew publishAllPublicationsToOssRepository --scan
run: ./gradlew publishAllPublicationsToOssRepository --scan -Dorg.gradle.parallel=false
env:
PUBLISHING: true
ORG_GRADLE_PROJECT_githubUsername: boswelja
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUB_TOKEN }}
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}

upload-pages:
runs-on: ubuntu-latest
build-pages:
runs-on: macos-latest
needs:
- publish-github
- publish-oss
Expand All @@ -79,7 +93,7 @@ jobs:
path: "build/dokka/htmlMultiModule/"

deploy-pages:
runs-on: ubuntu-latest
runs-on: macos-latest
needs: upload-pages
permissions:
pages: write
Expand Down
12 changes: 7 additions & 5 deletions bitrate/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,21 @@ signing {

publishing {
repositories {
if (System.getenv("PUBLISHING") == "true") {
val githubUsername = findProperty("githubUsername")?.toString()
val githubToken = findProperty("githubToken")?.toString()
if (githubUsername != null && githubToken != null) {
maven("https://maven.pkg.github.com/boswelja/kotlin-datatypes") {
val githubUsername: String? by project.properties
val githubToken: String? by project.properties
name = "github"
credentials {
username = githubUsername
password = githubToken
}
}
}
val ossrhUsername = findProperty("ossrhUsername")?.toString()
val ossrhPassword = findProperty("ossrhPassword")?.toString()
if (ossrhUsername != null && ossrhPassword != null) {
maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
val ossrhUsername: String? by project
val ossrhPassword: String? by project
name = "oss"
credentials {
username = ossrhUsername
Expand Down
12 changes: 7 additions & 5 deletions capacity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,21 @@ signing {

publishing {
repositories {
if (System.getenv("PUBLISHING") == "true") {
val githubUsername = findProperty("githubUsername")?.toString()
val githubToken = findProperty("githubToken")?.toString()
if (githubUsername != null && githubToken != null) {
maven("https://maven.pkg.github.com/boswelja/kotlin-datatypes") {
val githubUsername: String? by project.properties
val githubToken: String? by project.properties
name = "github"
credentials {
username = githubUsername
password = githubToken
}
}
}
val ossrhUsername = findProperty("ossrhUsername")?.toString()
val ossrhPassword = findProperty("ossrhPassword")?.toString()
if (ossrhUsername != null && ossrhPassword != null) {
maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
val ossrhUsername: String? by project
val ossrhPassword: String? by project
name = "oss"
credentials {
username = ossrhUsername
Expand Down
19 changes: 14 additions & 5 deletions percentage/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,30 @@ detekt {
basePath = rootDir.absolutePath
}

signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}

publishing {
repositories {
if (System.getenv("PUBLISHING") == "true") {
val githubUsername = findProperty("githubUsername")?.toString()
val githubToken = findProperty("githubToken")?.toString()
if (githubUsername != null && githubToken != null) {
maven("https://maven.pkg.github.com/boswelja/kotlin-datatypes") {
val githubUsername: String? by project.properties
val githubToken: String? by project.properties
name = "github"
credentials {
username = githubUsername
password = githubToken
}
}
}
val ossrhUsername = findProperty("ossrhUsername")?.toString()
val ossrhPassword = findProperty("ossrhPassword")?.toString()
if (ossrhUsername != null && ossrhPassword != null) {
maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
val ossrhUsername: String? by project
val ossrhPassword: String? by project
name = "oss"
credentials {
username = ossrhUsername
Expand Down
19 changes: 14 additions & 5 deletions temperature/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,30 @@ detekt {
basePath = rootDir.absolutePath
}

signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}

publishing {
repositories {
if (System.getenv("PUBLISHING") == "true") {
val githubUsername = findProperty("githubUsername")?.toString()
val githubToken = findProperty("githubToken")?.toString()
if (githubUsername != null && githubToken != null) {
maven("https://maven.pkg.github.com/boswelja/kotlin-datatypes") {
val githubUsername: String? by project.properties
val githubToken: String? by project.properties
name = "github"
credentials {
username = githubUsername
password = githubToken
}
}
}
val ossrhUsername = findProperty("ossrhUsername")?.toString()
val ossrhPassword = findProperty("ossrhPassword")?.toString()
if (ossrhUsername != null && ossrhPassword != null) {
maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
val ossrhUsername: String? by project
val ossrhPassword: String? by project
name = "oss"
credentials {
username = ossrhUsername
Expand Down

0 comments on commit 48696f5

Please sign in to comment.