Skip to content

Commit ca653bd

Browse files
committed
release & publish build scripts
1 parent f400878 commit ca653bd

File tree

3 files changed

+112
-33
lines changed

3 files changed

+112
-33
lines changed

.github/workflows/build.yml

+86-14
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,97 @@ name: Build CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ "master" ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ "master" ]
8+
release:
9+
types: [ published ]
10+
11+
# This allows a subsequently queued workflow run to interrupt previous runs
12+
concurrency:
13+
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
14+
cancel-in-progress: true
15+
16+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
17+
permissions:
18+
contents: read
19+
pages: write
20+
id-token: write
821

922
jobs:
1023
build:
1124

1225
runs-on: ubuntu-latest
1326

1427
steps:
15-
- uses: actions/checkout@v2
16-
- name: set up JDK 11
17-
uses: actions/setup-java@v2
18-
with:
19-
java-version: '11'
20-
distribution: 'adopt'
21-
cache: gradle
22-
23-
- name: Grant execute permission for gradlew
24-
run: chmod +x gradlew
25-
- name: Build with Gradle
26-
run: ./gradlew build
28+
- uses: actions/checkout@v3
29+
- name: set up JDK 11
30+
uses: actions/setup-java@v3
31+
with:
32+
java-version: '11'
33+
distribution: 'adopt'
34+
cache: gradle
35+
36+
- name: Grant execute permission for gradlew
37+
run: chmod +x gradlew
38+
- name: Build with Gradle
39+
env:
40+
PACKAGE_VERSION: ${{ github.event.release.tag_name }}
41+
run: ./gradlew build
42+
43+
release:
44+
if: ${{ github.event_name == 'release' }}
45+
runs-on: ubuntu-latest
46+
needs:
47+
- build
48+
steps:
49+
- uses: actions/checkout@v3
50+
51+
- name: Setup JDK 11
52+
uses: actions/setup-java@v3
53+
with:
54+
java-version: '11'
55+
distribution: 'adopt'
56+
cache: gradle
57+
58+
- name: Setup gradle
59+
uses: gradle/gradle-build-action@v2
60+
61+
- name: Release to sonatype
62+
env:
63+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
64+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
65+
GPG_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }}
66+
GPG_KEY_SECRET: ${{ secrets.GPG_KEY_SECRET }}
67+
PACKAGE_VERSION: ${{ github.event.release.tag_name }}
68+
run: ./gradlew publishJsPublicationToMavenRepository
69+
70+
publish:
71+
if: ${{ github.event_name == 'release' }}
72+
needs:
73+
- build
74+
environment:
75+
name: github-pages
76+
url: ${{ steps.deployment.outputs.page_url }}
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v3
81+
82+
- name: Setup Pages
83+
uses: actions/configure-pages@v3
84+
85+
- name: Setup gradle
86+
uses: gradle/gradle-build-action@v2
87+
88+
- name: Generate docs with dokka
89+
run: ./gradlew dokkaHtmlMultiModule
90+
91+
- name: Upload artifact
92+
uses: actions/upload-pages-artifact@v1
93+
with:
94+
path: ${{ github.workspace }}/build/dokka/htmlMultiModule
95+
96+
- name: Deploy to GitHub Pages
97+
id: deployment
98+
uses: actions/deploy-pages@v1

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ kotlin {
1616
binaries.executable()
1717
nodejs {
1818
dependencies {
19-
implementation("cz.sazel.sqldelight:node-sqlite3-driver-js:0.1.2-SNAPSHOT")
19+
implementation("cz.sazel.sqldelight:node-sqlite3-driver-js:0.1.3")
2020
}
2121
}
2222
}

build.gradle.kts

+25-18
Original file line numberDiff line numberDiff line change
@@ -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

2424
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
2629

30+
println("Package version $version")
2731

2832
repositories {
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

Comments
 (0)