Skip to content

Commit ae366f9

Browse files
authored
Merge pull request #22 from hotwired/publish-workflow
Setup workflow for publishing to GitHub Packages
2 parents 1664bb2 + 0aaa9d2 commit ae366f9

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

.github/workflows/publish.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish to GitHub Packages
2+
3+
on:
4+
release:
5+
types: [prereleased, released]
6+
7+
jobs:
8+
publish-release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Setup Java
12+
uses: actions/setup-java@v3
13+
with:
14+
distribution: 'temurin'
15+
java-version: '17'
16+
17+
- name: Checkout code
18+
uses: actions/checkout@v2
19+
20+
- name: Publish artifact to GitHub Packages
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
run: ./gradlew -Pversion=${{ github.event.release.tag_name }} clean build -x test publish --stacktrace

build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ plugins {
55
id("org.jetbrains.kotlin.android") version "1.9.22" apply false
66
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.22" apply false
77
}
8+
9+
tasks.register<Delete>("clean").configure {
10+
delete(rootProject.buildDir)
11+
}

core/build.gradle.kts

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,25 @@ plugins {
22
id("com.android.library")
33
id("org.jetbrains.kotlin.android")
44
id("org.jetbrains.kotlin.plugin.serialization")
5+
id("maven-publish")
56
}
67

8+
val libVersionName by extra(version as String)
9+
val libraryName by extra("Hotwire Native for Android")
10+
val libraryDescription by extra("Android framework for making Hotwire Native apps")
11+
12+
val publishedGroupId by extra("dev.hotwire")
13+
val publishedArtifactId by extra("core")
14+
15+
val siteUrl by extra("https://github.com/hotwired/hotwire-native-android")
16+
val gitUrl by extra("https://github.com/hotwired/hotwire-native-android.git")
17+
18+
val licenseType by extra("MIT License")
19+
val licenseUrl by extra("https://github.com/hotwired/hotwire-native-android/blob/main/LICENSE")
20+
21+
val developerId by extra("basecamp")
22+
val developerEmail by extra("androidteam@basecamp.com")
23+
724
android {
825
namespace = "dev.hotwire.core"
926
compileSdk = 34
@@ -44,6 +61,12 @@ android {
4461
named("test") { java { srcDirs("src/test/kotlin") } }
4562
named("debug") { java { srcDirs("src/debug/kotlin") } }
4663
}
64+
65+
publishing {
66+
singleVariant("release") {
67+
withSourcesJar()
68+
}
69+
}
4770
}
4871

4972
dependencies {
@@ -94,3 +117,55 @@ dependencies {
94117
testImplementation("com.squareup.okhttp3:mockwebserver:4.11.0")
95118
testImplementation("junit:junit:4.13.2")
96119
}
120+
121+
// Publish to GitHub Packages via:
122+
// ./gradlew -Pversion=<version> clean build publish
123+
// https://github.com/orgs/hotwired/packages?repo_name=hotwire-native-android
124+
publishing {
125+
publications {
126+
register<MavenPublication>("release") {
127+
groupId = publishedGroupId
128+
artifactId = publishedArtifactId
129+
version = libVersionName
130+
131+
pom {
132+
name.set(libraryName)
133+
description.set(libraryDescription)
134+
url.set(siteUrl)
135+
136+
licenses {
137+
license {
138+
name.set(licenseType)
139+
url.set(licenseUrl)
140+
}
141+
}
142+
developers {
143+
developer {
144+
id.set(developerId)
145+
name.set(developerId)
146+
email.set(developerEmail)
147+
}
148+
}
149+
scm {
150+
url.set(gitUrl)
151+
}
152+
}
153+
154+
// Applies the component for the release build variant
155+
afterEvaluate {
156+
from(components["release"])
157+
}
158+
}
159+
}
160+
repositories {
161+
maven {
162+
name = "GitHubPackages"
163+
url = uri("https://maven.pkg.github.com/hotwired/hotwire-native-android")
164+
165+
credentials {
166+
username = System.getenv("GITHUB_ACTOR")
167+
password = System.getenv("GITHUB_TOKEN")
168+
}
169+
}
170+
}
171+
}

0 commit comments

Comments
 (0)