Skip to content

Commit

Permalink
Kmp publishing (#71)
Browse files Browse the repository at this point in the history
* allure & compose

* Publish wf

* Update publish.yml

* Update publish.yml

* Update publish.yml

* Fix publications

* ultron-common publishing

* Fix allure listeners

* doc
  • Loading branch information
alex-tiurin authored Jun 24, 2024
1 parent 3ed5566 commit 753b91e
Show file tree
Hide file tree
Showing 12 changed files with 425 additions and 163 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Publish to Maven Central

permissions:
contents: read

on:
push:
branches:
- kmp-publishing

jobs:
publish:
env:
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
OSSRH_STAGING_PROFILE_ID: ${{ secrets.OSSRH_STAGING_PROFILE_ID }}
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
OSSRH_GPG_SECRET_KEY_ID: ${{ secrets.OSSRH_GPG_SECRET_KEY_ID }}

strategy:
matrix:
include:
- target: :ultron-compose:publishToSonatype
os: ubuntu-latest
- target: :ultron-android:publishToSonatype
os: ubuntu-latest
- target: :ultron-allure:publishToSonatype
os: ubuntu-latest
- target: :ultron-common:publishToSonatype
os: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

- name: Setup JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: "zulu"

- name: Setup Gradle cache
uses: actions/cache@v3
with:
path: |
~/.konan
key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}

- name: Gradle publish
run: ./gradlew "${{ matrix.target }}" closeAndReleaseSonatypeStagingRepository
21 changes: 4 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Ultron can be easially customised and extended. Wish you exclusively stable test
<img src="https://user-images.githubusercontent.com/12834123/252498170-61e5a440-c2b5-42ea-8bfb-91ee12248422.png#gh-dark-mode-only" width=600>
</p>

## [Documentation](https://open-tool.github.io/ultron/) | [Releases](https://github.com/open-tool/ultron/releases)

## What are the benefits of using the framework?

- Exceptional support for [**Compose**](https://github.com/open-tool/ultron/wiki/Compose)
Expand Down Expand Up @@ -247,21 +249,11 @@ For the complete guide, refer to the [wiki](https://github.com/open-tool/ultron/
fun setConfig() {
UltronConfig.applyRecommended()
UltronAllureConfig.applyRecommended()
UltronComposeConfig.applyRecommended()
}
```
![allure](https://github.com/open-tool/ultron/assets/12834123/c05c813a-ece6-45e6-a04f-e1c92b82ffb1)

for Compose add 4 lines more
```kotlin
@BeforeClass @JvmStatic
fun setConfig() {
...
UltronComposeConfig.applyRecommended()
UltronComposeConfig.addListener(ScreenshotAttachListener())
UltronComposeConfig.addListener(WindowHierarchyAttachListener())
UltronComposeConfig.addListener(DetailedOperationAllureListener())
}
```
![allure compose](https://github.com/open-tool/ultron/assets/12834123/1f751f3d-fc58-4874-a850-acd9181bfb70)


Expand All @@ -274,7 +266,7 @@ repositories {
}
dependencies {
androidTestImplementation 'com.atiurin:ultron:<latest_version>'
androidTestImplementation 'com.atiurin:ultron-android:<latest_version>'
androidTestImplementation 'com.atiurin:ultron-allure:<latest_version>'
androidTestImplementation 'com.atiurin:ultron-compose:<latest_version>'
}
Expand All @@ -284,8 +276,3 @@ Please, read [gradle dependencies management](https://github.com/open-tool/ultro
## AndroidX

It is required to use AndroidX libraries. You can get some problems with Android Support ones.

## Roadmap

- https://github.com/open-tool/ultron/issues/50 Meta information for UI elements
- https://github.com/open-tool/ultron/issues/33 Screenshot testign ?
18 changes: 18 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.compose.internal.utils.getLocalProperty

buildscript {
extra.apply {
set("RELEASE_REPOSITORY_URL", "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
Expand All @@ -7,6 +9,7 @@ buildscript {
repositories {
google()
mavenCentral()
mavenLocal()
}
dependencies {
classpath(Plugins.kotlinGradle)
Expand All @@ -25,13 +28,28 @@ plugins {
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.kotlinJvm) apply false
alias(libs.plugins.compose.compiler) apply false
id("io.github.gradle-nexus.publish-plugin").version("2.0.0-rc-1")
}

nexusPublishing {
repositories {
sonatype {
username
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(getLocalProperty("ossrhToken") ?: System.getenv("OSSRH_TOKEN"))
password.set(getLocalProperty("ossrhTokenPassword") ?: System.getenv("OSSRH_PASSWORD"))
stagingProfileId.set(getLocalProperty("sonatype.stagingProfileId") ?: System.getenv("OSSRH_STAGING_PROFILE_ID"))
}
}
}


allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
gradlePluginPortal()
}
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ object Versions {
const val kotlin = "2.0.0"
const val androidToolsBuildGradle = "8.3.1"
const val androidMavenGradlePlugin = "2.1"
const val publishPlugin = "0.13.0"
const val publishPlugin = "0.29.0"
const val dokkaPlugin = "1.9.20"

const val recyclerView = "1.2.1"
Expand Down
9 changes: 5 additions & 4 deletions docs/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ const config: Config = {
},
],
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
},
algolia: {
// The application ID provided by Algolia
appId: 'TLB3E9OO68',
Expand Down Expand Up @@ -135,10 +139,7 @@ const config: Config = {
// ],
// copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`,
// },
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
},

// https://docusaurus.io/blog/2021/11/21/algolia-docsearch-migration#docsearch-has-a-new-home
// algolia: {
// contextualSearch: true,
Expand Down
25 changes: 6 additions & 19 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,10 @@ kotlin.mpp.enableCInteropCommonization=true

GROUP=com.atiurin
POM_ARTIFACT_ID=ultron
VERSION_NAME=2.4.0-alpha01
VERSION_NAME=2.5.0-alpha04

POM_NAME=ultron

POM_PACKAGING=aar

POM_DESCRIPTION=Android UI testing framework
POM_INCEPTION_YEAR=2021

POM_URL=https://github.com/open-tool/ultron
POM_SCM_URL=https://github.com/open-tool/ultron
POM_SCM_CONNECTION=scm:[email protected]:open-tool/ultron.git
POM_SCM_DEV_CONNECTION=scm:[email protected]:open-tool/ultron.git

POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo

POM_DEVELOPER_NAME=Aleksei Tiurin
POM_DEVELOPER_URL=https://github.com/alex-tiurin
signing.gnupg.passphrase=${OSSRH_GPG_SECRET_KEY_PASSWORD}
signing.gnupg.keyName=${OSSRH_GPG_SECRET_KEY_ID}
sonatypeUsername=${OSSRH_TOKEN}
sonatypePassword=${OSSRH_PASSWORD}
sonatypeStagingProfileId=${OSSRH_STAGING_PROFILE_ID}
6 changes: 3 additions & 3 deletions sample-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ android {
}

dependencies {
implementation(project(":ultron-android"))
implementation(project(":ultron-compose"))
implementation(project(":ultron-allure"))
implementation("com.atiurin:ultron-android:2.5.0-alpha01")
implementation("com.atiurin:ultron-compose:2.5.0-alpha01")
implementation("com.atiurin:ultron-allure:2.5.0-alpha01")
implementation(Libs.kotlinStdlib)
implementation(Libs.coroutines)
implementation(Libs.appcompat)
Expand Down
103 changes: 71 additions & 32 deletions ultron-allure/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
plugins {
id("com.android.library")
id("kotlin-android")
id("com.vanniktech.maven.publish")
id("org.jetbrains.dokka")
id("maven-publish")
id("signing")
}

group = project.findProperty("GROUP")!!
version = project.findProperty("VERSION_NAME")!!


android {
compileSdk = 34
namespace = "com.atiurin.ultron.allure"
compileSdk = 34
defaultConfig {
minSdk = 21
}
Expand All @@ -27,6 +29,12 @@ android {
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_17
}

publishing {
singleVariant("release") {
withSourcesJar()
}
}
}
dependencies {
implementation(Libs.kotlinStdlib)
Expand All @@ -38,41 +46,72 @@ dependencies {
api(Libs.espressoCore)
}

tasks {
val sourcesJar by creating(Jar::class) {
archiveClassifier.set("sources")
from(tasks)
}
val dokkaOutputDir = buildDir.resolve("dokka")
tasks.dokkaHtml { outputDirectory.set(file(dokkaOutputDir)) }
val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") { delete(dokkaOutputDir) }
val javadocJar = tasks.register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
from(dokkaOutputDir)
}

val javadoc by creating(Javadoc::class) {
options {
this as StandardJavadocDocletOptions
addStringOption("Xdoclint:none", "-quiet")
addStringOption("Xmaxwarns", "1")
addStringOption("charSet", "UTF-8")
}
}
publishing {
publications {
create<MavenPublication>("release") {
artifact(javadocJar.get())
afterEvaluate {
from(components["release"])
}

val javadocJar by creating(Jar::class){
dependsOn(javadoc)
from(javadoc.destinationDir)
}
pom {
name.set("Ultron Allure")
description.set("Android & Compose Multiplatform UI testing framework")
url.set("https://github.com/open-tool/ultron")
inceptionYear.set("2021")

artifacts {
add("archives", sourcesJar)
add("archives", javadocJar)
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}

issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/open-tool/ultron/issues")
}

developers {
developer {
id.set("alex-tiurin")
name.set("Aleksei Tiurin")
url.set("https://github.com/open-tool")
}
}

scm {
connection.set("scm:[email protected]:open-tool/ultron.git")
developerConnection.set("scm:[email protected]:open-tool/ultron.git")
url.set("https://github.com/open-tool/ultron")
}
}
}
}
}

tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach {
dokkaSourceSets.configureEach {
// Configure Dokka source sets here
}
tasks.withType<PublishToMavenRepository>().configureEach {
dependsOn(tasks.withType<Sign>())
dependsOn(javadocJar)
mustRunAfter(tasks.withType<Sign>())
}
afterEvaluate {
tasks.findByName("generateMetadataFileForMavenPublication")?.let { generateMetadataTask ->
tasks.findByName("androidSourcesJar")?.let { androidSourcesJarTask ->
generateMetadataTask.dependsOn(androidSourcesJarTask)
}
}

tasks.named("generateMetadataFileForReleasePublication") {
dependsOn(javadocJar)
}

signing {
println("Signing lib...")
useGpgCmd()
sign(publishing.publications)
}
Loading

0 comments on commit 753b91e

Please sign in to comment.