Skip to content

Commit 0376716

Browse files
committed
Add github actions and maven publishing.
1 parent 77f990f commit 0376716

4 files changed

Lines changed: 96 additions & 45 deletions

File tree

.github/workflows/gradle.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# This workflow will assemble (compile) a Java project with Gradle
6+
# and cache/restore any dependencies to improve execution time.
7+
8+
name: Java Compile Only
9+
10+
on:
11+
push:
12+
branches: [ "main" ]
13+
pull_request:
14+
branches: [ "main" ]
15+
workflow_call:
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
compile:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v3
26+
27+
- name: Validate Gradle Wrapper
28+
uses: gradle/actions/wrapper-validation@v3
29+
30+
- uses: actions/cache@v3
31+
with:
32+
path: ~/.konan
33+
key: ${{ runner.os }}-${{ hashFiles('**/.lock') }}
34+
35+
- name: Set up JDK 17
36+
uses: actions/setup-java@v3
37+
with:
38+
java-version: '17'
39+
distribution: 'temurin'
40+
41+
- name: Compile (assemble) with Gradle
42+
uses: gradle/gradle-build-action@v3
43+
with:
44+
arguments: assemble

.github/workflows/publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# .github/workflows/publish.yml
2+
3+
name: Publish
4+
on:
5+
release:
6+
types: [released, prereleased]
7+
jobs:
8+
publish:
9+
name: Release build and publish
10+
runs-on: macOS-latest
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v4
14+
- name: Set up JDK 21
15+
uses: actions/setup-java@v4
16+
with:
17+
distribution: 'zulu'
18+
java-version: 21
19+
- name: Publish to MavenCentral
20+
run: ./gradlew html-screenshot:publishToMavenCentral --no-configuration-cache
21+
env:
22+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
23+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
24+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
25+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
26+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}

gradle.properties

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,24 @@ kotlin.mpp.enableCInteropCommonization=true
1010
#Android
1111
android.useAndroidX=true
1212
android.nonTransitiveRClass=true
13+
14+
GROUP=dev.robercoding
15+
POM_ARTIFACT_ID=html-screenshot
16+
VERSION_NAME=0.0.1-alpha01
17+
18+
POM_NAME=HTML Screenshot
19+
POM_DESCRIPTION=Take a screenshot of a webview loaded with local HTML and save it as image.
20+
POM_INCEPTION_YEAR=2025
21+
POM_URL=https://github.com/robercoding/html-screenshot-kmm
22+
23+
POM_LICENSE_NAME=The Apache Software License, Version 2.0
24+
POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
25+
POM_LICENSE_DIST=repo
26+
27+
POM_SCM_URL=https://github.com/robercoding/html-screenshot-kmm/
28+
POM_SCM_CONNECTION=scm:git:git://github.com/robercoding/html-screenshot-kmm.git
29+
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/robercoding/html-screenshot-kmm.git
30+
31+
POM_DEVELOPER_ID=robercoding
32+
POM_DEVELOPER_NAME=Roberto Fuentes
33+
POM_DEVELOPER_URL=https://github.com/robercoding/

html-screenshot/build.gradle.kts

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ kotlin {
3333
api(libs.kotlinx.coroutines.core)
3434
}
3535
}
36-
37-
// val iosMain by creating {
38-
// dependsOn(commonMain)
39-
// }
40-
// val iosSimulatorArm64Main by getting {
41-
// dependsOn(iosMain)
42-
// }
4336
val commonTest by getting {
4437
dependencies {
4538
implementation(libs.kotlin.test)
@@ -64,44 +57,11 @@ dependencies {
6457
}
6558

6659

67-
publishing {
68-
publications.withType<MavenPublication>().configureEach {
69-
groupId = project.group.toString()
60+
mavenPublishing {
61+
// Publish to the new Central Portal
62+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
7063

71-
artifactId = when (this.name) {
72-
"kotlinMultiplatform" -> project.name
73-
else -> {
74-
// source: https://github.com/orgs/community/discussions/26328#discussioncomment-3251482
75-
// artifactId should be lowercase to be able to push to github packages
76-
// This is a workaround to publish on GitHub Packages with lowercase artifactId
77-
// strip "Publication", insert dashes between camel-case transitions, lowercase
78-
// e.g: iosArm64Publication -> ios-arm64
79-
// e.g: iosX64Publication -> ios-x64
80-
// e.g: iosSimulatorArm64Publication -> ios-simulator-arm64
81-
val suffix = name
82-
.removeSuffix("Publication")
83-
.replace(Regex("([a-z])([A-Z])"), "$1-$2")
84-
.lowercase()
85-
"${project.name}-$suffix"
86-
}
87-
}
88-
89-
version = project.version.toString()
90-
}
91-
92-
// Publish
93-
repositories {
94-
maven {
95-
name = "GitHubPackages"
96-
url = uri("https://maven.pkg.github.com/robercoding/html-screenshot-kmm")
97-
// gradle property htmlScreenshot.githubActor
98-
val githubActor = System.getenv("GITHUB_ACTOR") ?: project.findProperty("htmlScreenshotGithubActor") as String
99-
val githubToken = System.getenv("GITHUB_TOKEN") ?: project.findProperty("htmlScreenshotGithubToken") as String
100-
credentials {
101-
username = githubActor
102-
password = githubToken
103-
}
104-
}
105-
}
64+
// Enable GPG signing of every publication
65+
signAllPublications()
10666
}
10767

0 commit comments

Comments
 (0)