Skip to content

Commit 18e8881

Browse files
committed
build: split publishing of natives and kotlin
1 parent 2ec5c04 commit 18e8881

File tree

3 files changed

+82
-42
lines changed

3 files changed

+82
-42
lines changed

.github/actions/deploy-ubuntu/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ runs:
317317
- name: Publish release
318318
shell: bash
319319
if: "github.event_name == 'release'"
320-
run: ./gradlew build publish -Pffmpeg.gpl=${{ matrix.gpl }} -Pdeploy.version=${{ github.event.release.tag_name }} --console=plain --info --configure-on-demand --parallel --build-cache
320+
run: ./gradlew build publish -Pdeploy.kotlin=false -Pdeploy.native=true -Pffmpeg.gpl=${{ matrix.gpl }} -Pdeploy.version=${{ github.event.release.tag_name }} --console=plain --info --configure-on-demand --parallel --build-cache
321321

322322
- name: Publish snapshot
323323
shell: bash
324324
if: "github.event_name != 'release'"
325-
run: ./gradlew build publish -Pffmpeg.gpl=${{ matrix.gpl }} --console=plain --info --configure-on-demand --parallel --build-cache
325+
run: ./gradlew build publish -Pdeploy.kotlin=false -Pdeploy.native=true -Pffmpeg.gpl=${{ matrix.gpl }} --console=plain --info --configure-on-demand --parallel --build-cache

.github/workflows/ffmpeg.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,26 @@ jobs:
135135
# steps:
136136
# - uses: actions/checkout@v4
137137
# - uses: ./.github/actions/redeploy
138+
deploy-kotlin:
139+
name: Publish Kotlin artifacts
140+
runs-on: ubuntu-22.04
141+
steps:
142+
- name: Setup Gradle
143+
uses: gradle/actions/setup-gradle@v3
144+
with:
145+
cache-encryption-key: ${{ inputs.gradle-cache-encryption-key }}
146+
gradle-home-cache-cleanup: true
147+
build-scan-publish: true
148+
build-scan-terms-of-use-url: "https://gradle.com/terms-of-service"
149+
build-scan-terms-of-use-agree: "yes"
150+
add-job-summary-as-pr-comment: on-failure
151+
152+
- name: Publish release
153+
shell: bash
154+
if: "github.event_name == 'release'"
155+
run: ./gradlew build publish -Pdeploy.native=false -Pdeploy.kotlin=true -Pffmpeg.gpl=${{ matrix.gpl }} -Pdeploy.version=${{ github.event.release.tag_name }} --console=plain --info --configure-on-demand --parallel --build-cache
156+
157+
- name: Publish snapshot
158+
shell: bash
159+
if: "github.event_name != 'release'"
160+
run: ./gradlew build publish -Pdeploy.native=false -Pdeploy.kotlin=true -Pffmpeg.gpl=${{ matrix.gpl }} --console=plain --info --configure-on-demand --parallel --build-cache

build.gradle.kts

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,52 +32,61 @@ dependencies {
3232
implementation(libs.jni.utils)
3333
}
3434

35-
val withGPL: Boolean = findProperty("ffmpeg.gpl")?.toString()?.toBoolean() ?: false
35+
val deployKotlin = (findProperty("deploy.kotlin") as String?)?.toBoolean() ?: true
36+
val deployNative = (findProperty("deploy.native") as String?)?.toBoolean() ?: true
37+
val withGPL: Boolean = findProperty("ffmpeg.gpl").toString().toBoolean()
3638
val platformExtension = "-gpl".takeIf { withGPL }.orEmpty()
3739
val platform = NativePlatform.platform(platformExtension)
3840

39-
val compileNative by tasks.registering(Exec::class) {
40-
commandLine(
41-
"bash",
42-
layout.projectDirectory.file("cppbuild.sh").asFile.absolutePath,
43-
"-extension", platform.extension,
44-
"-platform", platform.osArch,
45-
"install", "ffmpeg",
46-
)
47-
workingDir(layout.projectDirectory.asFile)
41+
val compileNative = if(deployNative) {
42+
tasks.register<Exec>("compileNative") {
43+
enabled = deployNative
44+
commandLine(
45+
"bash",
46+
layout.projectDirectory.file("cppbuild.sh").asFile.absolutePath,
47+
"-extension", platform.extension,
48+
"-platform", platform.osArch,
49+
"install", "ffmpeg",
50+
)
51+
workingDir(layout.projectDirectory.asFile)
4852

49-
inputs.property("platform", platform)
50-
inputs.files(layout.projectDirectory.files("cppbuild.sh"))
51-
inputs.files(layout.projectDirectory.files("detect-platform.sh"))
52-
inputs.files(layout.projectDirectory.files("ffmpeg/cppbuild.sh"))
53-
inputs.files(layout.projectDirectory.files("ffmpeg/*.patch"))
54-
inputs.files(layout.projectDirectory.files("ffmpeg/*.diff"))
55-
outputs.dir(layout.projectDirectory.dir("ffmpeg/cppbuild/${platform}"))
56-
outputs.cacheIf { true }
57-
}
53+
inputs.property("platform", platform)
54+
inputs.files(layout.projectDirectory.files("cppbuild.sh"))
55+
inputs.files(layout.projectDirectory.files("detect-platform.sh"))
56+
inputs.files(layout.projectDirectory.files("ffmpeg/cppbuild.sh"))
57+
inputs.files(layout.projectDirectory.files("ffmpeg/*.patch"))
58+
inputs.files(layout.projectDirectory.files("ffmpeg/*.diff"))
59+
outputs.dir(layout.projectDirectory.dir("ffmpeg/cppbuild/${platform}"))
60+
outputs.cacheIf { true }
61+
}
62+
} else null
5863

59-
tasks.processResources {
60-
val platform = NativePlatform.platform(platformExtension)
64+
val nativesJar = if (deployNative) {
65+
tasks.register<Jar>("nativesJar") {
66+
val platform = NativePlatform.platform(platformExtension)
6167

62-
from(compileNative.get().outputs.files) {
63-
include("lib/*.so")
64-
include("lib/*.dll")
65-
include("lib/*.dylib")
66-
eachFile {
67-
path = "natives/$platform/$name"
68+
from(compileNative!!.get().outputs.files) {
69+
include("lib/*.so")
70+
include("lib/*.dll")
71+
include("lib/*.dylib")
72+
eachFile {
73+
path = "natives/$platform/$name"
74+
}
75+
into("natives/$platform/")
6876
}
69-
into("natives/$platform/")
7077
}
71-
}
78+
} else null
7279

73-
val zipBuild by tasks.registering(Zip::class) {
74-
from(compileNative.get().outputs.files) {
75-
include("bin/**/*")
76-
include("include/**/*")
77-
include("lib/**/*")
78-
include("share/**/*")
80+
val zipBuild = if (deployNative) {
81+
tasks.register<Zip>("zipBuild") {
82+
from(compileNative!!.get().outputs.files) {
83+
include("bin/**/*")
84+
include("include/**/*")
85+
include("lib/**/*")
86+
include("share/**/*")
87+
}
7988
}
80-
}
89+
} else null
8190

8291
kotlin {
8392
compilerOptions {
@@ -93,10 +102,18 @@ java {
93102

94103
publishing {
95104
publications {
96-
create<MavenPublication>("native${platform.capitalized}") {
97-
from(components["java"])
98-
artifact(zipBuild)
99-
artifactId = "ffmpeg-natives-${platform}"
105+
if (deployNative) {
106+
create<MavenPublication>("native${platform.capitalized}") {
107+
artifact(nativesJar)
108+
artifact(zipBuild)
109+
artifactId = "ffmpeg-natives-${platform}"
110+
}
111+
}
112+
if (deployKotlin) {
113+
create<MavenPublication>("kotlin") {
114+
from(components["java"])
115+
artifactId = "ffmpeg-natives"
116+
}
100117
}
101118
}
102119

0 commit comments

Comments
 (0)