@@ -17,13 +17,17 @@ val localProperties = Properties().apply {
1717 try {
1818 load(project.rootProject.file(" local.properties" ).inputStream())
1919 } catch (e: java.io.IOException ) {
20- println (" Can't read local.properties, skipping" )
20+ System .err. println (" Can't read local.properties, skipping" )
2121 }
2222}
2323
2424group = System .getenv(" GROUP_ID" ) ? : localProperties[" groupId" ] as String? ? : defaultGroupId
25- version = System .getenv(" PACKAGE_VERSION" ) ? : localProperties[" packageVersion" ] as String? ? : " $versionBase -SNAPSHOT"
25+ var versionStr = System .getenv(" PACKAGE_VERSION" )?.trim()?.ifBlank { null }
26+ ? : localProperties[" packageVersion" ] as String? ? : " $versionBase -SNAPSHOT"
27+ if (versionStr.startsWith(" v" )) versionStr = versionStr.substring(1 )
28+ version = versionStr
2629
30+ println (" Package version $version " )
2731
2832repositories {
2933 mavenCentral()
@@ -32,8 +36,8 @@ repositories {
3236 url = uri(" https://maven.pkg.github.com/wojta/sqldelight-node-sqlite3-driver" ) // Github Package
3337 credentials {
3438 // Fetch these details from the properties file or from Environment variables
35- username = localProperties[" github.user" ] as String? ? : System .getenv( " GITHUB_USER " )
36- password = localProperties[" github.token" ] as String? ? : System .getenv( " GITHUB_TOKEN " )
39+ username = System .getenv( " GITHUB_USER " ) ? : localProperties[" github.user" ] as String?
40+ password = System .getenv( " GITHUB_TOKEN " ) ? : localProperties[" github.token" ] as String?
3741 }
3842 }
3943}
@@ -139,34 +143,37 @@ kotlin {
139143 }
140144
141145 repositories {
142- maven {
143- name = " GitHubPackages"
144- url = uri(" https://maven.pkg.github.com/wojta/sqldelight-node-sqlite3-driver" ) // Github Package
145-
146- credentials {
147- // Fetch these details from the properties file or from Environment variables
148- username = localProperties[" github.user" ] as String? ? : System .getenv(" GITHUB_USER" )
149- password = localProperties[" github.token" ] as String? ? : System .getenv(" GITHUB_TOKEN" )
146+ val githubUserName = System .getenv(" GITHUB_USER" ) ? : localProperties[" github.user" ] as String?
147+ if (githubUserName != null ) { // Github packages repo
148+ maven {
149+ name = " GitHubPackages"
150+ url = uri(" https://maven.pkg.github.com/wojta/sqldelight-node-sqlite3-driver" ) // Github Package
151+
152+ credentials {
153+ // Fetch these details from the properties file or from Environment variables
154+ username = githubUserName
155+ password = System .getenv(" GITHUB_TOKEN" ) ? : localProperties[" github.token" ] as String?
156+ }
150157 }
151158 }
152- maven {
159+ maven { // OSS Sonatype (default)
153160 val isSnapshot = version.toString().endsWith(" SNAPSHOT" )
154161 val destination = if (! isSnapshot) {
155162 " https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
156163 } else " https://s01.oss.sonatype.org/content/repositories/snapshots"
157164 url = uri(destination)
158165 credentials {
159- username = localProperties[" sonatype.user" ] as String? ? : System .getenv( " SONATYPE_USER " )
160- password = localProperties[" sonatype.password" ] as String? ? : System .getenv( " SONATYPE_PASSWORD " )
166+ username = System .getenv( " SONATYPE_USER " ) ? : localProperties[" sonatype.user" ] as String?
167+ password = System .getenv( " SONATYPE_PASSWORD " ) ? : localProperties[" sonatype.password" ] as String?
161168 }
162169 }
163170 }
164171 }
165- // val publishing = extensions.getByType<PublishingExtension>()
172+
166173 extensions.configure<SigningExtension > {
167174 useInMemoryPgpKeys(
168- localProperties[" gpg.keySecret" ] as String? ? : System .getenv( " GPG_KEY_SECRET " ) ,
169- localProperties[" gpg.keyPassword" ] as String? ? : System .getenv( " GPG_KEY_PASSWORD " )
175+ System .getenv( " GPG_KEY_SECRET " ) ? : localProperties[" gpg.keySecret" ] as String? ,
176+ System .getenv( " GPG_KEY_PASSWORD " ) ? : localProperties[" gpg.keyPassword" ] as String?
170177 )
171178
172179 sign(publishing.publications)
0 commit comments