Skip to content

Commit aea4cb3

Browse files
authored
build: Refactor release job to build all artifacts in a single environment (#139)
* Run release workflow on a single Linux machine * Remove condition for overlapping publications * Update RELEASING.md Closes #116
1 parent c611999 commit aea4cb3

File tree

3 files changed

+7
-73
lines changed

3 files changed

+7
-73
lines changed

.github/workflows/release.yml

+4-46
Original file line numberDiff line numberDiff line change
@@ -11,59 +11,17 @@ env:
1111
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
1212

1313
jobs:
14-
release_linux:
15-
name: Build release on main platform (Linux)
14+
release:
15+
name: Build and publish release
1616
runs-on: ubuntu-24.04
1717
steps:
1818
- name: Checkout
1919
uses: actions/checkout@v4
20-
- name: Set up JDK 11
20+
- name: Set up JDK
2121
uses: actions/setup-java@v4
2222
with:
2323
distribution: temurin
24-
java-version: 11
25-
- uses: gradle/actions/setup-gradle@v4
26-
with:
27-
gradle-version: wrapper
28-
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
29-
- run: ./gradlew publishToSonatype closeSonatypeStagingRepository
30-
- name: Create Github Release
31-
id: create_release
32-
uses: actions/create-release@v1
33-
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
with:
36-
tag_name: ${{ github.ref }}
37-
release_name: Release ${{ github.ref }}
38-
draft: false
39-
prerelease: false
40-
release_macos:
41-
name: Build release on MacOS
42-
runs-on: macos-latest
43-
steps:
44-
- name: Checkout
45-
uses: actions/checkout@v4
46-
- name: Set up JDK 11
47-
uses: actions/setup-java@v4
48-
with:
49-
distribution: zulu
50-
java-version: 11
51-
- uses: gradle/actions/setup-gradle@v4
52-
with:
53-
gradle-version: wrapper
54-
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
55-
- run: ./gradlew publishToSonatype closeSonatypeStagingRepository
56-
release_windows:
57-
name: Build release on Windows
58-
runs-on: windows-latest
59-
steps:
60-
- name: Checkout
61-
uses: actions/checkout@v4
62-
- name: Set up JDK 11
63-
uses: actions/setup-java@v4
64-
with:
65-
distribution: zulu
66-
java-version: 11
24+
java-version: 17
6725
- uses: gradle/actions/setup-gradle@v4
6826
with:
6927
gradle-version: wrapper

RELEASING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
1. Push a new git tag of a format 'v*', e.g. v1.0.0
2-
2. Github Actions workflow will start, building release and pushing it to maven central. It will then create a github release.
3-
3. Update github release with release notes.
1+
1. Create a Github release with a new tag in a format `vX.Y.Z`, e.g. `v0.1.2`
2+
2. Github Actions workflow will start, building release and pushing it to maven central.
3+
3. Staging repositories on Sonatype will be closed automatically, but need to be released manually.

buildSrc/src/main/kotlin/io/github/petertrr/PublishingConfiguration.kt

-24
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,6 @@ fun Project.configurePublishing() {
4242
if (hasProperty("sonatypeUsername")) {
4343
configureNexusPublishing()
4444
}
45-
46-
// https://kotlinlang.org/docs/mpp-publish-lib.html#avoid-duplicate-publications
47-
// Publication with name `kotlinMultiplatform` is for the default artifact.
48-
// `configureNexusPublishing` adds sonatype publication tasks inside `afterEvaluate`.
49-
rootProject.afterEvaluate {
50-
val publicationsFromMainHost = listOf("jvm", "js", "linuxX64", "kotlinMultiplatform", "metadata")
51-
configure<PublishingExtension> {
52-
publications.matching { it.name in publicationsFromMainHost }.all {
53-
val targetPublication = this@all
54-
tasks.withType<AbstractPublishToMaven>()
55-
.matching { it.publication == targetPublication }
56-
.configureEach {
57-
onlyIf {
58-
// main publishing CI job is executed on Linux host
59-
DefaultNativePlatform.getCurrentOperatingSystem().isLinux.apply {
60-
if (!this) {
61-
logger.lifecycle("Publication ${(it as AbstractPublishToMaven).publication.name} is skipped on current host")
62-
}
63-
}
64-
}
65-
}
66-
}
67-
}
68-
}
6945
}
7046

7147
private fun Project.configurePublications() {

0 commit comments

Comments
 (0)