Skip to content

Commit

Permalink
Add wasmJs and linuxArm64 targets (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt authored Apr 27, 2024
1 parent 1da87c5 commit b8e5925
Show file tree
Hide file tree
Showing 16 changed files with 374 additions and 172 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build

on:
pull_request:
paths-ignore:
- 'docs/**'
- 'samples/**'
- '*.md'
push:
branches:
- 'master'
paths-ignore:
- 'docs/**'
- 'samples/**'
- '*.md'

jobs:
test:
strategy:
matrix:
os: [ macos-latest, windows-latest, ubuntu-latest ]
include:
- os: macos-latest
TEST_TASK: macosArm64Test
- os: windows-latest
TEST_TASK: mingwX64Test
- os: ubuntu-latest
TEST_TASK: apiCheck check
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/actions/setup-gradle@v3
with:
arguments: ${{matrix.TEST_TASK}} --stacktrace
- name: Bundle the build report
if: failure()
run: find . -type d -name 'reports' | zip -@ -r build-reports.zip
- name: Upload the build report
if: failure()
uses: actions/upload-artifact@master
with:
name: error-report
path: build-reports.zip
publish:
needs: test
runs-on: macos-latest
if: ${{ github.ref == 'refs/heads/master' && github.repository == 'ajalt/clikt' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- name: Deploy to sonatype
uses: gradle/actions/setup-gradle@v3
with:
# disable configuration cache due to https://github.com/gradle/gradle/issues/22779
arguments: publishToMavenCentral -PsnapshotVersion=true --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralPassword }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKey }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralUsername }}

env:
GRADLE_OPTS: -Dorg.gradle.configureondemand=true -Dorg.gradle.parallel=true -Dkotlin.incremental=false -Dorg.gradle.project.kotlin.incremental.multiplatform=false -Dorg.gradle.project.kotlin.native.disableCompilerDaemon=true -Dorg.gradle.jvmargs="-Xmx6g -Dfile.encoding=UTF-8"
9 changes: 4 additions & 5 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: "Validate Gradle Wrapper"
on:
push:
paths:
- 'gradle/wrapper/**'
pull_request:
paths:
- 'gradle/wrapper/**'
- 'gradlew'
- 'gradlew.bat'
- 'gradle/wrapper/'
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/actions/wrapper-validation@v3
82 changes: 0 additions & 82 deletions .github/workflows/publish.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: release

on:
push:
tags:
- '**'

jobs:
release:
runs-on: macos-latest
if: ${{ github.ref == 'refs/heads/master' && github.repository == 'ajalt/clikt' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/actions/setup-gradle@v3
with:
# disable configuration cache due to https://github.com/gradle/gradle/issues/22779
arguments: publishToMavenCentral --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralPassword }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKey }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralUsername }}

env:
# configureondemand=false to work around KT-51763
GRADLE_OPTS: -Dorg.gradle.configureondemand=false -Dorg.gradle.parallel=true -Dkotlin.incremental=false -Dorg.gradle.project.kotlin.incremental.multiplatform=false -Dorg.gradle.project.kotlin.native.disableCompilerDaemon=true -Dorg.gradle.jvmargs="-Xmx6g -Dfile.encoding=UTF-8"
50 changes: 0 additions & 50 deletions .github/workflows/test.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ dependencies {

#### Multiplatform

Clikt supports the following targets: `jvm`, `mingwX64`, `linuxX64`, `macosX64`, `macosArm64'`,
and `js` (for both Node.js and Browsers). [See the
Clikt supports the following targets: `jvm`, `mingwX64`, `linuxX64`, `linuxArm64`, `macosX64`, `macosArm64'`,
and `js` and `wasmJs` (for both Node.js and Browsers). [See the
docs](https://ajalt.github.io/clikt/advanced/#multiplatform-support) for more information about
functionality supported on each target. You'll need to use Gradle 6 or newer.

Expand Down
19 changes: 4 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
import java.io.ByteArrayOutputStream


plugins {
Expand All @@ -17,21 +16,11 @@ apiValidation {
}

fun getPublishVersion(): String {
val versionName = project.property("VERSION_NAME") as String
// Call gradle with -PinferVersion to set the dynamic version name.
// Otherwise, we skip it to save time.
if (!project.hasProperty("inferVersion")) return versionName

val stdout = ByteArrayOutputStream()
project.exec {
commandLine = listOf("git", "tag", "--points-at", "HEAD")
standardOutput = stdout
}
val tag = String(stdout.toByteArray()).trim()
if (tag.isNotEmpty()) return tag

val version = project.property("VERSION_NAME").toString()
// Call gradle with -PsnapshotVersion to set the version as a snapshot.
if (!project.hasProperty("snapshotVersion")) return version
val buildNumber = System.getenv("GITHUB_RUN_NUMBER") ?: "0"
return "$versionName.$buildNumber-SNAPSHOT"
return "$version.$buildNumber-SNAPSHOT"
}


Expand Down
21 changes: 21 additions & 0 deletions clikt/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
@file:Suppress("UNUSED_VARIABLE", "KotlinRedundantDiagnosticSuppress")

import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask


plugins {
kotlin("multiplatform")
alias(libs.plugins.publish)
Expand All @@ -11,8 +16,13 @@ kotlin {
nodejs()
browser()
}
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
nodejs()
}

linuxX64()
linuxArm64()
mingwX64()
macosX64()
macosArm64()
Expand All @@ -39,3 +49,14 @@ kotlin {
}
}
}

// https://youtrack.jetbrains.com/issue/KT-63014
// https://github.com/Kotlin/kotlin-wasm-examples/blob/1b007347bf9f8a1ec3d420d30de1815768d5df02/nodejs-example/build.gradle.kts#L22
rootProject.the<NodeJsRootExtension>().apply {
nodeVersion = "22.0.0-nightly202404032241e8c5b3"
nodeDownloadBaseUrl = "https://nodejs.org/download/nightly"
}

rootProject.tasks.withType<KotlinNpmInstallTask>().configureEach {
args.add("--ignore-engines")
}
Loading

0 comments on commit b8e5925

Please sign in to comment.