Skip to content

Commit 2f95636

Browse files
committed
Add a "Publish Release" GitHub action
1 parent f24d36f commit 2f95636

File tree

4 files changed

+56
-9
lines changed

4 files changed

+56
-9
lines changed

.github/workflows/publish-release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name : Publish Release
2+
3+
on :
4+
workflow_dispatch:
5+
6+
jobs :
7+
publish-release :
8+
runs-on : ubuntu-latest
9+
if : github.repository == 'square/workflow-kotlin'
10+
timeout-minutes : 35
11+
12+
steps :
13+
- uses : actions/checkout@v3
14+
- uses : gradle/wrapper-validation-action@v1
15+
16+
- name : Ensure this isn't a -SNAPSHOT version
17+
uses : ./.github/actions/gradle-task
18+
with :
19+
task : checkVersionIsNotSnapshot
20+
21+
- name : Assemble
22+
uses : ./.github/actions/gradle-task
23+
with :
24+
task : assemble
25+
26+
- name : Check
27+
uses : ./.github/actions/gradle-task
28+
with :
29+
task : check -x artifactsCheck
30+
31+
- name : Publish Release
32+
uses : ./.github/actions/gradle-task
33+
with :
34+
task : publish
35+
env :
36+
ORG_GRADLE_PROJECT_mavenCentralUsername : ${{ secrets.SONATYPE_NEXUS_USERNAME }}
37+
ORG_GRADLE_PROJECT_mavenCentralPassword : ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
38+
ORG_GRADLE_PROJECT_signingInMemoryKey : ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}

.github/workflows/publish-snapshot.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
branches:
77
- main
88

9-
env:
10-
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx12g -Dorg.gradle.daemon=false -Dorg.gradle.logging.stacktrace=all"
11-
129
jobs:
1310
publish-snapshot:
1411
runs-on: workflow-kotlin-test-runner-ubuntu-4core

RELEASING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@
3030
git tag v0.1.0
3131
```
3232

33-
1. Upload the kotlin artifacts:
33+
1. Push those changes to the repository:
3434
```bash
35-
./gradlew clean && ./gradlew build && ./gradlew publish
35+
git push
3636
```
3737

38-
1. Close and release the staging repository at https://s01.oss.sonatype.org/#stagingRepositories.
38+
1. Run the `Publish Release` action in the [GitHub Actions](https://github.com/square/workflow-kotlin/actions/workflows/publish-release.yml) page by clicking "run workflow" on the right.
3939

40-
1. Bump the version
40+
1. Wait for that publishing job to succeed.
41+
42+
1. Back on your local machine, bump the version
4143
- **Kotlin:** Update the `VERSION_NAME` property in `gradle.properties` to the new
4244
snapshot version, e.g. `VERSION_NAME=0.2.0-SNAPSHOT`.
4345

build-logic/src/main/java/com/squareup/workflow1/buildsrc/PublishingConventionPlugin.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import org.gradle.api.publish.maven.MavenPublication
1313
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
1414

1515
class PublishingConventionPlugin : Plugin<Project> {
16-
1716
override fun apply(target: Project) {
1817
target.plugins.apply("org.jetbrains.dokka")
1918
target.plugins.apply("com.vanniktech.maven.publish.base")
@@ -37,8 +36,19 @@ class PublishingConventionPlugin : Plugin<Project> {
3736
}
3837
}
3938

39+
target.tasks.register("checkVersionIsNotSnapshot") { task ->
40+
task.group = "publishing"
41+
task.description = "ensures that the project version does not have a -SNAPSHOT suffix"
42+
val versionString = target.version as String
43+
task.doLast {
44+
require(!versionString.endsWith("-SNAPSHOT")) {
45+
"The project's version name cannot have a -SNAPSHOT suffix, but it was $versionString."
46+
}
47+
}
48+
}
49+
4050
target.extensions.configure(MavenPublishBaseExtension::class.java) { basePluginExtension ->
41-
basePluginExtension.publishToMavenCentral(SonatypeHost.S01)
51+
basePluginExtension.publishToMavenCentral(SonatypeHost.S01, automaticRelease = true)
4252
// Will only apply to non snapshot builds.
4353
basePluginExtension.signAllPublications()
4454
// import all settings from root project and project-specific gradle.properties files

0 commit comments

Comments
 (0)