@@ -17,13 +17,17 @@ val localProperties = Properties().apply {
17
17
try {
18
18
load(project.rootProject.file(" local.properties" ).inputStream())
19
19
} catch (e: java.io.IOException ) {
20
- println (" Can't read local.properties, skipping" )
20
+ System .err. println (" Can't read local.properties, skipping" )
21
21
}
22
22
}
23
23
24
24
group = 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
26
29
30
+ println (" Package version $version " )
27
31
28
32
repositories {
29
33
mavenCentral()
@@ -32,8 +36,8 @@ repositories {
32
36
url = uri(" https://maven.pkg.github.com/wojta/sqldelight-node-sqlite3-driver" ) // Github Package
33
37
credentials {
34
38
// 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?
37
41
}
38
42
}
39
43
}
@@ -139,34 +143,37 @@ kotlin {
139
143
}
140
144
141
145
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
+ }
150
157
}
151
158
}
152
- maven {
159
+ maven { // OSS Sonatype (default)
153
160
val isSnapshot = version.toString().endsWith(" SNAPSHOT" )
154
161
val destination = if (! isSnapshot) {
155
162
" https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
156
163
} else " https://s01.oss.sonatype.org/content/repositories/snapshots"
157
164
url = uri(destination)
158
165
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?
161
168
}
162
169
}
163
170
}
164
171
}
165
- // val publishing = extensions.getByType<PublishingExtension>()
172
+
166
173
extensions.configure<SigningExtension > {
167
174
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?
170
177
)
171
178
172
179
sign(publishing.publications)
0 commit comments