Skip to content

Commit

Permalink
Setup publishing for native targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Aug 28, 2020
1 parent 979c890 commit d95d2db
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 40 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Gradle CI

on: [push, pull_request]

jobs:
build-on-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build

build-on-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
# This is a basic workflow to help you get started with Actions
name: Publishing

name: Publish

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
release:
types:
- created

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
runs-on: ubuntu-latest
publish-runtime-on-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Gradle clean
run: ./gradlew clean
- name: Gradle build
run: ./gradlew build # if test's failed, don't publish
- name: Check keys
run: ./gradlew :kotlin-jvm-blocking-bridge:ensureBintrayAvailable
-Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }}
-Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
- name: :kotlin-jvm-blocking-bridge:publish
run: ./gradlew
:kotlin-jvm-blocking-bridge:publish
-Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }}
-Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}

publish-runtime-on-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
Expand All @@ -28,31 +46,54 @@ jobs:
run: ./gradlew build # if test's failed, don't publish
- name: Check keys
run: ./gradlew :kotlin-jvm-blocking-bridge:ensureBintrayAvailable
:kotlin-jvm-blocking-bridge-compiler:ensureBintrayAvailable
:kotlin-jvm-blocking-bridge-compiler-embeddable:ensureBintrayAvailable
:kotlin-jvm-blocking-bridge-gradle:ensureBintrayAvailable
-Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }}
-Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}
- name: :kotlin-jvm-blocking-bridge:publish
run: ./gradlew
:kotlin-jvm-blocking-bridge:publish
-Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }}
-Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}

publish-others-on-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Gradle clean
run: ./gradlew clean
- name: Gradle build
run: ./gradlew build # if test's failed, don't publish
- name: Check keys
run: ./gradlew :kotlin-jvm-blocking-bridge:ensureBintrayAvailable
:kotlin-jvm-blocking-bridge-compiler:ensureBintrayAvailable
:kotlin-jvm-blocking-bridge-compiler-embeddable:ensureBintrayAvailable
:kotlin-jvm-blocking-bridge-gradle:ensureBintrayAvailable
-Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }}
-Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}

- name: :kotlin-jvm-blocking-bridge-compiler:bintrayUpload
run: ./gradlew
:kotlin-jvm-blocking-bridge-compiler:bintrayUpload
-Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }}
-Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}

- name: :kotlin-jvm-blocking-bridge-compiler-embeddable:bintrayUpload
run: ./gradlew
:kotlin-jvm-blocking-bridge-compiler-embeddable:bintrayUpload
-Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }}
-Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}

- name: :kotlin-jvm-blocking-bridge-gradle:bintrayUpload
run: ./gradlew
:kotlin-jvm-blocking-bridge-gradle:bintrayUpload
-Dbintray_user=${{ secrets.BINTRAY_USER }} -Pbintray_user=${{ secrets.BINTRAY_USER }}
-Dbintray_key=${{ secrets.BINTRAY_KEY }} -Pbintray_key=${{ secrets.BINTRAY_KEY }}

- name: Publish Gradle plugin
run: ./gradlew
:kotlin-jvm-blocking-bridge-gradle:publishPlugins
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/main.yml

This file was deleted.

2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object Versions {
const val project = "1.0.3"
const val project = "1.0.4"
const val idePlugin = "1.2.0"

const val kotlin = "1.4.0"
Expand Down
1 change: 1 addition & 0 deletions ide-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ tasks.getByName("publishPlugin", org.jetbrains.intellij.tasks.PublishTask::class
}

tasks.withType<org.jetbrains.intellij.tasks.PatchPluginXmlTask> {
sinceBuild("193.*")
untilBuild("205.*")
}

Expand Down
10 changes: 2 additions & 8 deletions runtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ kotlin {
js {
useCommonJs()
}
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
apply(from = file("gradle/compile-native-multiplatform.gradle"))

}

sourceSets {
Expand Down
71 changes: 71 additions & 0 deletions runtime/gradle/compile-native-multiplatform.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

project.ext.ideaActive = System.getProperty('idea.active') == 'true'

kotlin {
targets {
def hostOs = System.getProperty("os.name")

def linuxEnabled = hostOs == "Mac OS X"
def macosEnabled = hostOs == "Linux"
def winEnabled = hostOs.startsWith("Windows")

project.ext.isLinuxHost = linuxEnabled
project.ext.isMacosHost = macosEnabled
project.ext.isWinHost = winEnabled

if (project.ext.ideaActive) {
def ideaPreset = presets.linuxX64
if (macosEnabled) ideaPreset = presets.macosX64
if (winEnabled) ideaPreset = presets.mingwX64
project.ext.ideaPreset = ideaPreset
}
}
}

project.ext.nativeMainSets = []
project.ext.nativeTestSets = []

kotlin {
targets.metaClass.addTarget = { preset ->
def target = delegate.fromPreset(preset, preset.name)
project.ext.nativeMainSets.add(target.compilations['main'].kotlinSourceSets.first())
project.ext.nativeTestSets.add(target.compilations['test'].kotlinSourceSets.first())
}

targets {
if (project.ext.ideaActive) {
fromPreset(project.ext.ideaPreset, 'native')
} else {
addTarget(presets.linuxX64)
addTarget(presets.iosArm64)
addTarget(presets.iosArm32)
addTarget(presets.iosX64)
addTarget(presets.macosX64)
addTarget(presets.mingwX64)
addTarget(presets.tvosArm64)
addTarget(presets.tvosX64)
addTarget(presets.watchosArm32)
addTarget(presets.watchosArm64)
addTarget(presets.watchosX86)
}
}

sourceSets {
nativeMain { dependsOn commonMain }
// Empty source set is required in order to have native tests task
nativeTest {}

if (!project.ext.ideaActive) {
configure(nativeMainSets) {
dependsOn nativeMain
}

configure(nativeTestSets) {
dependsOn nativeTest
}
}
}
}

0 comments on commit d95d2db

Please sign in to comment.