Skip to content

Commit

Permalink
Move build files and remove submodule (#127)
Browse files Browse the repository at this point in the history
* Move build plugins from pubnub-kotlin, remove submodule

* Add NPM publishing configs

* Change runner to macos, automate Swift package publishing

* Add `kotlin` and `js` products for releasing
  • Loading branch information
wkal-pubnub authored Dec 4, 2024
1 parent 3052402 commit 66bfe86
Show file tree
Hide file tree
Showing 78 changed files with 15,956 additions and 2,437 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/commands-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Process command
if: github.event.issue.pull_request && endsWith(github.repository, '-private') != true
runs-on:
group: organization/Default
group: macos-gh
steps:
- name: Check referred user
id: user-check
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/release-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: JS automated product release

on:
pull_request:
branches: [master]
types: [closed]
paths:
- 'js-chat/.pubnub.yml'

jobs:
check-release:
name: Check release required
if: github.event.pull_request.merged && endsWith(github.repository, '-private') != true
runs-on:
group: macos-gh
outputs:
release: ${{ steps.check.outputs.ready }}
steps:
- name: Checkout actions
uses: actions/checkout@v4
with:
repository: pubnub/client-engineering-deployment-tools
ref: v1
token: ${{ secrets.GH_TOKEN }}
path: .github/.release/actions
- id: check
name: Check pre-release completed
uses: ./.github/.release/actions/actions/checks/release
with:
token: ${{ secrets.GH_TOKEN }}
publish:
name: Publish package
needs: check-release
if: needs.check-release.outputs.release == 'true'
runs-on:
group: macos-gh
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# This should be the same as the one specified for on.pull_request.branches
ref: master
submodules: recursive
- name: Checkout actions
uses: actions/checkout@v4
with:
repository: pubnub/client-engineering-deployment-tools
ref: v1
token: ${{ secrets.GH_TOKEN }}
path: .github/.release/actions
- name: Publish to NPM
uses: ./.github/.release/actions/actions/services/npm
with:
token: ${{ secrets.GH_TOKEN }}
npm-token: ${{ secrets.NPM_TOKEN }}
check-ownership: false
package-path: package.json
actions: "build,publish"
build-command: npm run build
build-path: dist
last-service: true
# - name: Update Pages
# uses: ./.github/.release/actions/actions/services/github-pages
# with:
# token: ${{ secrets.GH_TOKEN }}
# source-folder: build/dokka/gfmMultiModule
# jira-api-key: ${{ secrets.JIRA_API_KEY }}
# last-service: true
# - name: Upload test reports
# uses: ./.github/.release/actions/actions/test-reports/upload
# with:
# token: ${{ secrets.GH_TOKEN }}
# acceptance-tests-workflow: Tests
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
name: Automated product release
name: Kotlin automated product release

on:
pull_request:
branches: [master]
types: [closed]
paths:
- '.pubnub.yml'

jobs:
check-release:
name: Check release required
if: github.event.pull_request.merged && endsWith(github.repository, '-private') != true
runs-on:
group: organization/Default
group: macos-gh
outputs:
release: ${{ steps.check.outputs.ready }}
steps:
Expand All @@ -31,7 +33,7 @@ jobs:
needs: check-release
if: needs.check-release.outputs.release == 'true'
runs-on:
group: organization/Default
group: macos-gh
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -61,6 +63,7 @@ jobs:
uses: ./.github/.release/actions/actions/services/github-release
with:
token: ${{ secrets.GH_TOKEN }}
artifacts-folder: build/gh_artifacts
prepend-product-to-tag: true
last-service: true
# - name: Update Pages
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/release/chat-maven-build.sh

This file was deleted.

10 changes: 10 additions & 0 deletions .github/workflows/release/js-pre-npm-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
echo "Build JS Chat SDK module artifacts"
pushd ..
./gradlew :jsNodeProductionLibraryDistribution
./gradlew :packJsPackage
mkdir -p js-chat/dist
cp build/packages/js/package.json js-chat/package.json
cp build/packages/js/index.d.ts js-chat/dist/
cp build/packages/js/index.d.ts js-chat/dist/index.es.d.ts
popd
npm run build
11 changes: 11 additions & 0 deletions .github/workflows/release/kotlin-maven-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -e
echo "Build Kotlin and Swift Chat SDK module artifacts"
./gradlew -PENABLE_TARGET_IOS_ALL=true :podPublishReleaseXCFramework assemble
find build/cocoapods/publish/release/PubNubChat.xcframework -exec touch -t 00000000 {} +
rm -f build/cocoapods/publish/release/PubNubChat.xcframework.zip
zip -X -vr build/cocoapods/publish/release/PubNubChat.xcframework.zip build/cocoapods/publish/release/PubNubChat.xcframework
touch -t 00000000 build/cocoapods/publish/release/PubNubChat.xcframework.zip
CHECKSUM=$(swift package compute-checksum /Users/wojciech.kalicinski/projects/pubnub-chat/build/cocoapods/publish/release/PubNubChat.xcframework.zip)
echo $CHECKSUM
mkdir build/gh_artifacts
mv build/cocoapods/publish/release/PubNubChat.xcframework.zip build/gh_artifacts/
11 changes: 11 additions & 0 deletions .github/workflows/release/kotlin-pre-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -e
echo "Update Swift Chat SDK checksum in Package.swift"
./gradlew -PENABLE_TARGET_IOS_ALL=true :podPublishReleaseXCFramework
find build/cocoapods/publish/release/PubNubChat.xcframework -exec touch -t 00000000 {} +
rm -f build/cocoapods/publish/release/PubNubChat.xcframework.zip
zip -X -vr build/cocoapods/publish/release/PubNubChat.xcframework.zip build/cocoapods/publish/release/PubNubChat.xcframework
touch -t 00000000 build/cocoapods/publish/release/PubNubChat.xcframework.zip
CHECKSUM=$(swift package compute-checksum /Users/wojciech.kalicinski/projects/pubnub-chat/build/cocoapods/publish/release/PubNubChat.xcframework.zip)
echo $CHECKSUM
sed -i.bak "s/checksum: \"[a-z0-9]*\"/checksum: \"$CHECKSUM\"/g" Package.swift
rm Package.swift.bak
8 changes: 7 additions & 1 deletion .github/workflows/release/products.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"chat": {
"kotlin": {
"path": "./",
"name": "PubNub Kotlin Chat SDK",
"main": true,
"overrideRelease": true
},
"js": {
"path": "./js-chat",
"name": "PubNub JS Chat SDK",
"main": true,
"overrideRelease": true
}
}
14 changes: 14 additions & 0 deletions .github/workflows/release/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,19 @@
"clearedPrefix": true,
"clearedSuffix": false
}
],
"Package.swift": [
{
"pattern": "https://github.com/pubnub/kmp-chat/releases/download/chat-(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)",
"clearedPrefix": true,
"clearedSuffix": false
}
],
"package.json": [
{
"pattern": "^\\s{2,}\"version\": \"(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\",$",
"clearedPrefix": true,
"clearedSuffix": false
}
]
}
6 changes: 3 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
tests:
name: Integration and Unit tests
runs-on:
group: organization/Default
group: macos-gh
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
${{ runner.os }}-gradle-
- name: Build and run tests
run: |
./gradlew check -i
./gradlew check
env:
SDK_PUB_KEY: ${{ secrets.SDK_PUB_KEY }}
SDK_SUB_KEY: ${{ secrets.SDK_SUB_KEY }}
Expand All @@ -51,7 +51,7 @@ jobs:
name: Tests
needs: [tests]
runs-on:
group: organization/Default
group: macos-gh
steps:
- name: Tests summary
run: echo -e "\033[38;2;95;215;0m\033[1mAll tests successfully passed"
6 changes: 3 additions & 3 deletions .github/workflows/run-validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
pubnub-yml:
name: "Validate .pubnub.yml"
runs-on:
group: organization/Default
group: macos-gh
steps:
- name: Checkout project
uses: actions/checkout@v4
Expand All @@ -37,7 +37,7 @@ jobs:
build-validation:
name: Validate build
runs-on:
group: organization/Default
group: macos-gh
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
name: Validations
needs: [pubnub-yml, build-validation]
runs-on:
group: organization/Default
group: macos-gh
steps:
- name: Validations summary
run: echo -e "\033[38;2;95;215;0m\033[1mAll validations passed"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ build/
*.podspec
node_modules
js-chat/dist
test.properties

### IntelliJ IDEA ###
.idea/modules.xml
Expand Down Expand Up @@ -45,3 +46,6 @@ bin/
### Mac OS ###
.DS_Store
.idea

node_modules
js-chat/dist
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
[submodule "pubnub-kotlin"]
path = pubnub-kotlin
url = https://github.com/pubnub/kotlin.git
branch = master
6 changes: 5 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import PackageDescription

let package = Package(
name: "PubNubChat",
platforms: [.iOS(.v14)],
platforms: [
.iOS(.v14),
.macOS(.v11),
.tvOS(.v14)
],
products: [
.library(
name: "PubNubChat",
Expand Down
42 changes: 42 additions & 0 deletions build-logic/gradle-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
`java-gradle-plugin`
alias(libs.plugins.kotlin.jvm)
}

dependencies {
compileOnly(gradleKotlinDsl())
compileOnly(libs.nexus.gradlePlugin)
compileOnly(libs.vanniktech.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
compileOnly(libs.ktlint.gradlePlugin)
compileOnly(libs.dokka.gradlePlugin)
}

gradlePlugin {
plugins {
register("pubnubShared") {
id = "pubnub.shared"
implementationClass = "com.pubnub.gradle.PubNubSharedPlugin"
}
register("pubnubDokka") {
id = "pubnub.dokka"
implementationClass = "com.pubnub.gradle.PubNubDokkaPlugin"
}
register("pubnubKotlinLibrary") {
id = "pubnub.kotlin-library"
implementationClass = "com.pubnub.gradle.PubNubKotlinLibraryPlugin"
}
register("pubnubIosSimulatorTest") {
id = "pubnub.ios-simulator-test"
implementationClass = "com.pubnub.gradle.PubNubIosSimulatorTestPlugin"
}
register("pubnubMultiplatform") {
id = "pubnub.multiplatform"
implementationClass = "com.pubnub.gradle.PubNubKotlinMultiplatformPlugin"
}
register("pubnubBaseMultiplatform") {
id = "pubnub.base.multiplatform"
implementationClass = "com.pubnub.gradle.PubNubBaseKotlinMultiplatformPlugin"
}
}
}
3 changes: 3 additions & 0 deletions build-logic/gradle-plugins/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.gradle.parallel=false
org.gradle.caching=true
org.gradle.configuration-cache=true
19 changes: 19 additions & 0 deletions build-logic/gradle-plugins/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}
dependencyResolutionManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
versionCatalogs {
create("libs") {
from(files("../../gradle/libs.versions.toml"))
}
}
}

rootProject.name = "gradle-plugins"
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.pubnub.gradle

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.withType
import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.dokka.gradle.DokkaTaskPartial

class PubNubDokkaPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
apply<DokkaPlugin>()

tasks.withType<DokkaTask>().configureEach { task ->
task.notCompatibleWithConfigurationCache("https://github.com/Kotlin/dokka/issues/2231")
task.dokkaSourceSets.configureEach { sourceSetBuilder ->
sourceSetBuilder.perPackageOption {
it.matchingRegex.set(".*internal.*")
it.suppress.set(true)
}
sourceSetBuilder.skipEmptyPackages.set(true)
}
}

tasks.withType<DokkaTaskPartial>().configureEach { task ->
task.dokkaSourceSets.configureEach {
it.perPackageOption {
it.matchingRegex.set(".*internal.*")
it.suppress.set(true)
}
it.skipEmptyPackages.set(true)
}
}
}
}
}
Loading

0 comments on commit 66bfe86

Please sign in to comment.