@@ -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+
724android {
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
4972dependencies {
@@ -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