|
1 | 1 | plugins { |
2 | 2 | id("com.android.library") |
3 | 3 | id("org.jetbrains.kotlin.android") |
| 4 | + id("maven-publish") |
4 | 5 | } |
5 | 6 |
|
| 7 | +val libVersionName by extra(version as String) |
| 8 | +val libraryName by extra("Hotwire Native for Android - Fragment Navigation") |
| 9 | +val libraryDescription by extra("Android framework for making Hotwire Native apps") |
| 10 | + |
| 11 | +val publishedGroupId by extra("dev.hotwire") |
| 12 | +val publishedArtifactId by extra("navigation-fragments") |
| 13 | + |
| 14 | +val siteUrl by extra("https://github.com/hotwired/hotwire-native-android") |
| 15 | +val gitUrl by extra("https://github.com/hotwired/hotwire-native-android.git") |
| 16 | + |
| 17 | +val licenseType by extra("MIT License") |
| 18 | +val licenseUrl by extra("https://github.com/hotwired/hotwire-native-android/blob/main/LICENSE") |
| 19 | + |
| 20 | +val developerId by extra("basecamp") |
| 21 | +val developerEmail by extra("androidteam@basecamp.com") |
| 22 | + |
6 | 23 | android { |
7 | 24 | namespace = "dev.hotwire.navigation" |
8 | 25 | compileSdk = 34 |
@@ -46,6 +63,12 @@ android { |
46 | 63 | named("test") { java { srcDirs("src/test/kotlin") } } |
47 | 64 | named("debug") { java { srcDirs("src/debug/kotlin") } } |
48 | 65 | } |
| 66 | + |
| 67 | + publishing { |
| 68 | + singleVariant("release") { |
| 69 | + withSourcesJar() |
| 70 | + } |
| 71 | + } |
49 | 72 | } |
50 | 73 |
|
51 | 74 | dependencies { |
@@ -81,4 +104,55 @@ dependencies { |
81 | 104 | testImplementation("junit:junit:4.13.2") |
82 | 105 | } |
83 | 106 |
|
84 | | -// TODO add publishing support |
| 107 | +// Publish to GitHub Packages via: |
| 108 | +// ./gradlew -Pversion=<version> clean build publish |
| 109 | +// https://github.com/orgs/hotwired/packages?repo_name=hotwire-native-android |
| 110 | +publishing { |
| 111 | + publications { |
| 112 | + register<MavenPublication>("release") { |
| 113 | + groupId = publishedGroupId |
| 114 | + artifactId = publishedArtifactId |
| 115 | + version = libVersionName |
| 116 | + |
| 117 | + pom { |
| 118 | + name.set(libraryName) |
| 119 | + description.set(libraryDescription) |
| 120 | + url.set(siteUrl) |
| 121 | + |
| 122 | + licenses { |
| 123 | + license { |
| 124 | + name.set(licenseType) |
| 125 | + url.set(licenseUrl) |
| 126 | + } |
| 127 | + } |
| 128 | + developers { |
| 129 | + developer { |
| 130 | + id.set(developerId) |
| 131 | + name.set(developerId) |
| 132 | + email.set(developerEmail) |
| 133 | + } |
| 134 | + } |
| 135 | + scm { |
| 136 | + url.set(gitUrl) |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + // Applies the component for the release build variant |
| 141 | + afterEvaluate { |
| 142 | + from(components["release"]) |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + repositories { |
| 147 | + maven { |
| 148 | + name = "GitHubPackages" |
| 149 | + url = uri("https://maven.pkg.github.com/hotwired/hotwire-native-android") |
| 150 | + |
| 151 | + credentials { |
| 152 | + username = System.getenv("GITHUB_ACTOR") |
| 153 | + password = System.getenv("GITHUB_TOKEN") |
| 154 | + } |
| 155 | + } |
| 156 | + } |
| 157 | +} |
| 158 | + |
0 commit comments