Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "Publish Release" GitHub action #1164

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name : Publish Release

on :
workflow_dispatch:

jobs :
publish-release :
runs-on : ubuntu-latest
if : github.repository == 'square/workflow-kotlin'
timeout-minutes : 35

steps :
- uses : actions/checkout@v3
- uses : gradle/wrapper-validation-action@v1

- name : Ensure this isn't a -SNAPSHOT version
uses : ./.github/actions/gradle-task
with :
task : checkVersionIsNotSnapshot

- name : Assemble
uses : ./.github/actions/gradle-task
with :
task : assemble

- name : Check
uses : ./.github/actions/gradle-task
with :
task : check -x artifactsCheck

- name : Publish Release
uses : ./.github/actions/gradle-task
with :
task : publish
env :
ORG_GRADLE_PROJECT_mavenCentralUsername : ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword : ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey : ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
3 changes: 0 additions & 3 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
branches:
- main

env:
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx12g -Dorg.gradle.daemon=false -Dorg.gradle.logging.stacktrace=all"

jobs:
publish-snapshot:
runs-on: workflow-kotlin-test-runner-ubuntu-4core
Expand Down
10 changes: 6 additions & 4 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@
git tag v0.1.0
```

1. Upload the kotlin artifacts:
1. Push those changes to the repository:
```bash
./gradlew clean && ./gradlew build && ./gradlew publish
git push
```

1. Close and release the staging repository at https://s01.oss.sonatype.org/#stagingRepositories.
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.

1. Bump the version
1. Wait for that publishing job to succeed.

1. Back on your local machine, bump the version
- **Kotlin:** Update the `VERSION_NAME` property in `gradle.properties` to the new
snapshot version, e.g. `VERSION_NAME=0.2.0-SNAPSHOT`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository

class PublishingConventionPlugin : Plugin<Project> {

override fun apply(target: Project) {
target.plugins.apply("org.jetbrains.dokka")
target.plugins.apply("com.vanniktech.maven.publish.base")
Expand All @@ -37,8 +36,19 @@ class PublishingConventionPlugin : Plugin<Project> {
}
}

target.tasks.register("checkVersionIsNotSnapshot") { task ->
task.group = "publishing"
task.description = "ensures that the project version does not have a -SNAPSHOT suffix"
val versionString = target.version as String
task.doLast {
require(!versionString.endsWith("-SNAPSHOT")) {
"The project's version name cannot have a -SNAPSHOT suffix, but it was $versionString."
}
}
}

target.extensions.configure(MavenPublishBaseExtension::class.java) { basePluginExtension ->
basePluginExtension.publishToMavenCentral(SonatypeHost.S01)
basePluginExtension.publishToMavenCentral(SonatypeHost.S01, automaticRelease = true)
// Will only apply to non snapshot builds.
basePluginExtension.signAllPublications()
// import all settings from root project and project-specific gradle.properties files
Expand Down
Loading