Skip to content

build: Refactor release job to build all artifacts in a single environment #139

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 1 commit into from
May 6, 2025
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
50 changes: 4 additions & 46 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,17 @@ env:
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

jobs:
release_linux:
name: Build release on main platform (Linux)
release:
name: Build and publish release
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 11
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- run: ./gradlew publishToSonatype closeSonatypeStagingRepository
- name: Create Github Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
release_macos:
name: Build release on MacOS
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- run: ./gradlew publishToSonatype closeSonatypeStagingRepository
release_windows:
name: Build release on Windows
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
java-version: 17
- uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper
Expand Down
6 changes: 3 additions & 3 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
1. Push a new git tag of a format 'v*', e.g. v1.0.0
2. Github Actions workflow will start, building release and pushing it to maven central. It will then create a github release.
3. Update github release with release notes.
1. Create a Github release with a new tag in a format `vX.Y.Z`, e.g. `v0.1.2`
2. Github Actions workflow will start, building release and pushing it to maven central.
3. Staging repositories on Sonatype will be closed automatically, but need to be released manually.
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,6 @@ fun Project.configurePublishing() {
if (hasProperty("sonatypeUsername")) {
configureNexusPublishing()
}

// https://kotlinlang.org/docs/mpp-publish-lib.html#avoid-duplicate-publications
// Publication with name `kotlinMultiplatform` is for the default artifact.
// `configureNexusPublishing` adds sonatype publication tasks inside `afterEvaluate`.
rootProject.afterEvaluate {
val publicationsFromMainHost = listOf("jvm", "js", "linuxX64", "kotlinMultiplatform", "metadata")
configure<PublishingExtension> {
publications.matching { it.name in publicationsFromMainHost }.all {
val targetPublication = this@all
tasks.withType<AbstractPublishToMaven>()
.matching { it.publication == targetPublication }
.configureEach {
onlyIf {
// main publishing CI job is executed on Linux host
DefaultNativePlatform.getCurrentOperatingSystem().isLinux.apply {
if (!this) {
logger.lifecycle("Publication ${(it as AbstractPublishToMaven).publication.name} is skipped on current host")
}
}
}
}
}
}
}
}

private fun Project.configurePublications() {
Expand Down
Loading