Skip to content

Commit 61a89be

Browse files
authored
Merge pull request #16 from jGleitz/semantic-release-bot
chore: Setup for semantic release bot
2 parents d932c0d + b92eb75 commit 61a89be

File tree

3 files changed

+56
-63
lines changed

3 files changed

+56
-63
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
47

58
jobs:
69

@@ -30,43 +33,19 @@ jobs:
3033
- name: Build
3134
run: ./gradlew build
3235

33-
docs:
34-
name: Publish Snapshot
36+
release:
37+
name: Release
3538
runs-on: ubuntu-latest
39+
needs: build
3640
if: github.ref == 'refs/heads/master'
3741
steps:
3842
- name: Checkout
3943
uses: actions/checkout@v2
40-
- name: Cache
41-
uses: actions/cache@v1
42-
with:
43-
path: ~/.gradle
44-
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle.kts') }}
45-
restore-keys: |
46-
gradle-${{ runner.os }}
47-
gradle-
48-
- name: Set up JDK
49-
uses: actions/setup-java@v1
50-
with:
51-
java-version: 8
52-
- name: Prepare
53-
run: ./gradlew clean dependencies
54-
- name: Assemble
55-
run: ./gradlew assemble
56-
env:
57-
ORG_GRADLE_PROJECT_githubRepository: ${{ github.repository }}
58-
- name: Publish Documentation
59-
uses: peaceiris/[email protected]
60-
env:
61-
ACTIONS_DEPLOY_KEY: ${{ secrets.GH_PAGES_DEPLOY_KEY }}
62-
PUBLISH_BRANCH: gh-pages
63-
PUBLISH_DIR: ./build/dokka
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v1
6446
with:
65-
emptyCommits: false
66-
- name: Publish Snapshot Artifacts
67-
run: ./gradlew publishSnapshot
47+
node-version: 12
48+
- name: Release
6849
env:
69-
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.PACKAGE_SIGNING_KEY }}
70-
ORG_GRADLE_PROJECT_signingKeyPassword: ${{ secrets.PACKAGE_SIGNING_KEY_PASSWORD }}
71-
ORG_GRADLE_PROJECT_githubRepository: ${{ github.repository }}
72-
ORG_GRADLE_PROJECT_githubToken: ${{ github.token }}
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
run: npx semantic-release@17

.github/workflows/release.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66

77
jobs:
88
publish:
9+
name: Publish Artefacts
910
runs-on: ubuntu-latest
1011
steps:
1112
- name: Checkout
@@ -21,7 +22,7 @@ jobs:
2122
- name: Set up JDK
2223
uses: actions/setup-java@v1
2324
with:
24-
java-version: 8
25+
java-version: 13
2526
- name: Prepare
2627
run: ./gradlew clean dependencies
2728
- name: Release to Maven Central
@@ -32,3 +33,36 @@ jobs:
3233
ORG_GRADLE_PROJECT_githubRepository: ${{ github.repository }}
3334
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
3435
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}
36+
37+
docs:
38+
name: Publish Documentation
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v2
43+
- name: Cache
44+
uses: actions/cache@v1
45+
with:
46+
path: ~/.gradle
47+
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle.kts') }}
48+
restore-keys: |
49+
gradle-${{ runner.os }}
50+
gradle-
51+
- name: Set up JDK
52+
uses: actions/setup-java@v1
53+
with:
54+
java-version: 13
55+
- name: Prepare
56+
run: ./gradlew clean dependencies
57+
- name: Assemble
58+
run: ./gradlew dokka
59+
env:
60+
ORG_GRADLE_PROJECT_githubRepository: ${{ github.repository }}
61+
- name: Publish Documentation
62+
uses: peaceiris/[email protected]
63+
env:
64+
ACTIONS_DEPLOY_KEY: ${{ secrets.GH_PAGES_DEPLOY_KEY }}
65+
PUBLISH_BRANCH: gh-pages
66+
PUBLISH_DIR: ./build/dokka
67+
with:
68+
emptyCommits: false

build.gradle.kts

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ artifacts {
7878
}
7979

8080
lateinit var publication: MavenPublication
81-
lateinit var snapshotRepository: ArtifactRepository
8281
lateinit var releaseRepository: NexusRepository
8382

8483
publishing {
@@ -92,14 +91,14 @@ publishing {
9291
name.set(provider { "$groupId:$artifactId" })
9392
description.set("Convert between different string notations commonly found in programming")
9493
inceptionYear.set("2020")
95-
url.set("https://github.com/jGleitz/string-notation")
94+
url.set("https://github.com/$githubRepository")
9695
ciManagement {
9796
system.set("GitHub Actions")
98-
url.set("https://github.com/jGleitz/string-notation/actions")
97+
url.set("https://github.com/$githubRepository/actions")
9998
}
10099
issueManagement {
101100
system.set("GitHub Issues")
102-
url.set("https://github.com/jGleitz/string-notation/issues")
101+
url.set("https://github.com/$githubRepository/issues")
103102
}
104103
developers {
105104
developer {
@@ -108,9 +107,9 @@ publishing {
108107
}
109108
}
110109
scm {
111-
connection.set("scm:git:https://github.com/jGleitz/string-notation.git")
112-
developerConnection.set("scm:git:git://[email protected]:jGleitz/string-notation.git")
113-
url.set("https://github.com/jGleitz/string-notation")
110+
connection.set("scm:git:https://github.com/$githubRepository.git")
111+
developerConnection.set("scm:git:git://[email protected]:$githubRepository.git")
112+
url.set("https://github.com/$githubRepository")
114113
}
115114
licenses {
116115
license {
@@ -122,15 +121,6 @@ publishing {
122121
}
123122
}
124123
}
125-
repositories {
126-
snapshotRepository = maven("https://maven.pkg.github.com/$githubRepository") {
127-
name = "GitHubPackages"
128-
credentials {
129-
username = githubOwner
130-
password = githubToken
131-
}
132-
}
133-
}
134124
}
135125

136126
nexusPublishing {
@@ -155,20 +145,12 @@ nexusStaging {
155145
}
156146

157147
val closeAndReleaseRepository by project.tasks
158-
val publish by tasks
159-
160-
task("publishSnapshot") {
161-
group = "publishing"
162-
description = "Publishes a snapshot of the project to GitHub Packages"
163-
dependsOn(snapshotRepository.publishTask)
164-
}
148+
closeAndReleaseRepository.mustRunAfter(releaseRepository.publishTask)
165149

166150
task("release") {
167151
group = "release"
168152
description = "Releases the project to Maven Central"
169-
dependsOn(releaseRepository.publishTask)
170-
dependsOn(closeAndReleaseRepository)
171-
closeAndReleaseRepository.mustRunAfter(releaseRepository.publishTask)
153+
dependsOn(releaseRepository.publishTask, closeAndReleaseRepository)
172154
}
173155

174156
idea {
@@ -185,6 +167,4 @@ fun String.drop(prefix: String) = if (this.startsWith(prefix)) this.drop(prefix.
185167
val Project.versionDetails
186168
get() = (this.extra["versionDetails"] as groovy.lang.Closure<*>)() as com.palantir.gradle.gitversion.VersionDetails
187169

188-
189-
val ArtifactRepository.publishTask get() = tasks["publishAllPublicationsTo${this.name}Repository"]
190170
val NexusRepository.publishTask get() = tasks["publishTo${this.name.capitalize()}"]

0 commit comments

Comments
 (0)