Skip to content

Commit 73f0e36

Browse files
feat: publish iOS frameworks to repository (#18)
1 parent 051e0f4 commit 73f0e36

File tree

10 files changed

+94
-59
lines changed

10 files changed

+94
-59
lines changed

.github/workflows/release.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
semantic-release:
12-
name: "Semantic Release"
12+
name: "Semantic Release & Generate Cocoapods artifacts"
1313
runs-on: macos-latest
1414
env:
1515
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
@@ -23,6 +23,14 @@ jobs:
2323
with:
2424
fetch-depth: 0
2525
ref: main
26+
submodules: recursive
27+
- name: "Install JDK 11"
28+
uses: actions/setup-java@v2
29+
with:
30+
distribution: "zulu"
31+
java-version: "11"
32+
- name: Install Cocoapods
33+
run: sudo gem install cocoapods; sudo gem install cocoapods-generate
2634
- name: "Import GPG Key"
2735
uses: crazy-max/ghaction-import-gpg@v4
2836
with:
@@ -54,7 +62,6 @@ jobs:
5462
if: ${{ github.event.inputs.dryRun == 'false' }}
5563
run: |
5664
git push origin main
57-
5865
sonatype-release:
5966
name: "Sonatype (Maven Central) Release"
6067
needs: semantic-release

.scripts/release.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ sed -i '.bak' "s/\"com.mparticle:api:.*\"/\"com.mparticle:api:$1\"/g" README.md
99
sed -i '.bak' "s/\"com.mparticle:models:.*\"/\"com.mparticle:models:$1\"/g" README.md
1010
sed -i '.bak' "s/\"com.mparticle:testing:.*\"/\"com.mparticle:testing:$1\"/g" README.md
1111

12+
sed -i '.bak' "s/\"version\": \".*\"/\"version\": \"$1\"/g" mParticle_Internal.podspec.json
13+
sed -i '.bak' "s/\"tag\": \".*\"/\"tag\": \"$1\"/g" mParticle_Internal.podspec.json
1214
#commit the version bump, tag, and push to private and public
1315
git add gradle.properties
1416
git add README.md

Tests/build.gradle.kts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
2+
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
3+
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
24

35
plugins {
46
id("com.android.library")
@@ -8,25 +10,16 @@ plugins {
810
}
911

1012
kotlin {
11-
val iOSTarget = if (System.getenv("SDK_NAME")
12-
?.startsWith("iphoneos") == true
13-
) presets.getByName("iosArm64") else presets.getByName("iosX64")
14-
1513
android {
1614
publishLibraryVariants("debug")
1715
}
18-
val onPhone = System.getenv("SDK_NAME")?.startsWith("iphoneos") ?: false
19-
if (onPhone) {
20-
iosArm64("ios") {
21-
binaries.framework(listOf(org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG))
22-
23-
}
24-
} else {
25-
iosX64("ios") {
26-
binaries.framework(listOf(org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType.DEBUG))
27-
16+
val xcFramework = XCFramework()
17+
ios {
18+
binaries.framework(listOf(NativeBuildType.RELEASE)) {
19+
xcFramework.add(this)
2820
}
2921
}
22+
3023
cocoapods {
3124
framework {
3225
summary = "Cross Platform Testing"
@@ -95,9 +88,9 @@ val installTestPods by tasks.creating(Exec::class.java) {
9588

9689

9790
val runIos by tasks.creating(Exec::class.java) {
98-
val linkDebugFrameworkIos = tasks.findByName("linkDebugFrameworkIos")
99-
dependsOn("linkDebugFrameworkIos")
100-
linkDebugFrameworkIos?.dependsOn(installTestPods)
91+
val linkReleaseFrameworkIos = tasks.findByName("linkReleaseFrameworkIosX64")
92+
dependsOn(linkReleaseFrameworkIos)
93+
linkReleaseFrameworkIos?.dependsOn(installTestPods)
10194
installTestPods.dependsOn("podImport")
10295
description = "Builds the iOS application bundle using Xcode."
10396
workingDir = project.file("helpers/XCodeTest")

api/build.gradle.kts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,9 @@ kotlin {
2020
}
2121
}
2222
val xcFramework = XCFramework()
23-
val onPhone = System.getenv("SDK_NAME")?.startsWith("iphoneos") ?: false
24-
if (onPhone) {
25-
iosArm64("ios") {
26-
binaries.framework(listOf(NativeBuildType.DEBUG)) {
27-
xcFramework.add(this)
28-
}
29-
}
30-
} else {
31-
iosX64("ios") {
32-
binaries.framework(listOf(NativeBuildType.DEBUG)) {
33-
xcFramework.add(this)
34-
}
23+
ios {
24+
binaries.framework(listOf(NativeBuildType.RELEASE)) {
25+
xcFramework.add(this)
3526
}
3627
}
3728

build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ subprojects {
1515
tasks.register("publishAndroid") { dependsOn("publishAndroidDebugPublicationToMavenLocal") }
1616
}
1717
}
18+
19+
afterEvaluate {
20+
val copyXCFramework = tasks.register<Copy>("copyXCFramework") {
21+
from("build/cocoapods/publish/release")
22+
into("$rootDir/frameworks")
23+
}
24+
25+
tasks.findByName("podPublishReleaseXCFramework")?.finalizedBy(copyXCFramework)
26+
}
1827
}
1928

2029
val appleSDKTempDirPath = "${project.rootDir.absolutePath}/.sdks/apple-testing"

mParticle_Internal.podspec.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "mParticle-Cross-Platform",
3+
"version": "1.1.0",
4+
"summary": "mParticle Internal Tools generated using Kotlin Multiplatform",
5+
"description": "A collection on internal crossplatform tools and packages",
6+
"homepage": "https://www.mparticle.com",
7+
"license": {
8+
"type": "Apache 2.0",
9+
"file": "LICENSE"
10+
},
11+
"authors": {
12+
"mParticle": "[email protected]"
13+
},
14+
"source": {
15+
"git": "https://github.com/mParticle/crossplatform-sdk-tests.git",
16+
"tag": "1.1.0"
17+
},
18+
"default_subspecs": "Testing",
19+
"subspecs": [
20+
{
21+
"name": "Api",
22+
"vendored_frameworks": [
23+
"frameworks/mParticle_Api.xcframework"
24+
]
25+
},
26+
{
27+
"name": "Mocking",
28+
"vendored_frameworks": [
29+
"frameworks/mParticle_mocking.xcframework"
30+
]
31+
},
32+
{
33+
"name": "Models",
34+
"vendored_frameworks": [
35+
"frameworks/mParticle_Models.xcframework"
36+
]
37+
},
38+
{
39+
"name": "Testing",
40+
"vendored_frameworks": [
41+
"frameworks/mParticle_testing.xcframework"
42+
]
43+
},
44+
{
45+
"name": "Tests",
46+
"vendored_frameworks": [
47+
"frameworks/mParticle_Multiplatform_Tests.xcframework"
48+
]
49+
}
50+
]
51+
}

models/build.gradle.kts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,9 @@ kotlin {
2424
artifactId = project.name
2525
}
2626
}
27-
val onPhone = System.getenv("SDK_NAME")?.startsWith("iphoneos") ?: false
28-
if (onPhone) {
29-
iosArm64("ios") {
30-
binaries.framework(listOf(NativeBuildType.DEBUG)) {
31-
xcFramework.add(this)
32-
}
33-
34-
}
35-
} else {
36-
iosX64("ios") {
37-
binaries.framework(listOf(NativeBuildType.DEBUG)) {
38-
xcFramework.add(this)
39-
}
27+
ios {
28+
binaries.framework(listOf(NativeBuildType.RELEASE)) {
29+
xcFramework.add(this)
4030
}
4131
}
4232

overview.drawio

Whitespace-only changes.

release.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ module.exports = {
3535
[
3636
"@semantic-release/exec",
3737
{
38-
prepareCmd: "sh ./.scripts/release.sh ${nextRelease.version}",
38+
prepareCmd: "sh ./.scripts/release.sh ${nextRelease.version}; ./gradlew podPublishReleaseXCFramework",
3939
},
4040
],
4141
["@semantic-release/github"],
4242
[
4343
"@semantic-release/git",
4444
{
45-
assets: ["CHANGELOG.md", "gradle.properties", "README.md"],
45+
assets: ["CHANGELOG.md", "gradle.properties", "README.md", "frameworks", "mParticle_Internal.podspec.json"],
4646
message:
4747
"chore(release): ${nextRelease.version} \n\n${nextRelease.notes}",
4848
},

testing/build.gradle.kts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,17 @@ kotlin {
1717
}
1818
}
1919
val xcFramework = XCFramework()
20-
val onPhone = System.getenv("SDK_NAME")?.startsWith("iphoneos") ?: false
21-
if (onPhone) {
22-
iosArm64("ios") {
23-
binaries.framework(listOf(NativeBuildType.DEBUG)) {
24-
xcFramework.add(this)
25-
}
26-
}
27-
} else {
28-
iosX64("ios") {
29-
binaries.framework(listOf(NativeBuildType.DEBUG)) {
30-
xcFramework.add(this)
31-
}
20+
ios {
21+
binaries.framework(listOf(NativeBuildType.RELEASE)) {
22+
xcFramework.add(this)
3223
}
3324
}
25+
3426
cocoapods {
3527
framework {
3628
summary = "Cross Platform Testing"
3729
homepage = "."
38-
baseName = "mParticle_testing"
30+
baseName = "mParticle_Testing"
3931
ios.deploymentTarget = "14.3"
4032
}
4133
pod("mParticle-Apple-SDK/mParticle", path = project.file("../.sdks/apple-testing"))

0 commit comments

Comments
 (0)