Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Commit

Permalink
Add more release infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
JLLeitschuh committed Mar 10, 2022
1 parent 55f85d8 commit 8e542fd
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ jobs:
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
GITHUB_KEY: ${{ secrets.GithubKey }}
GITHUB_KEY: ${{ secrets.GITHUB_TOKEN }}
run: ./plugin/gradlew -p ./plugin githubRelease --no-daemon
36 changes: 36 additions & 0 deletions .github/workflows/prepare-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Prepare for Release"
on:
workflow_dispatch:
inputs:
new_version:

description: "Release Version (no 'v')"
required: true
type: string

jobs:
prepare-changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Update Changelog
uses: thomaseizinger/[email protected]
with:
tag: v${{ github.event.inputs.new_version }}
version: ${{ github.event.inputs.new_version }}
- name: Update README
run: |
stripped_version=$(echo "${{ github.event.inputs.new_version }}" | sed -e 's/\.//g')
formatted_date=$(date "+%Y%m%d")
sed 's|\(Latest plugin version: \[\).*\(\](/CHANGELOG.md#\).*---.*)|\1'"$stripped_version"'\21031---'"$formatted_date"')|' README.md
- name: Update VERSION_CURRENT
run: echo "${{ github.event.inputs.new_version }}\n" > plugin/VERSION_CURRENT.txt
- uses: actions/upload-artifact@v3
with:
name: changed_files
path: |
CHANGELOG.md
README.md
plugin/VERSION_CURRENT.txt
plugin/VERSION_LATEST_RELEASE.txt
25 changes: 0 additions & 25 deletions .github/workflows/prepare_release.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

**Provides a convenient wrapper plugin over the [ktlint](https://github.com/pinterest/ktlint) project.**

<!-- Note: if changing the line below, the `sed` command in the prepare-release.yaml needs to be updated too -->
Latest plugin version: [10.2.1](/CHANGELOG.md#1021---20211227)

[![Join the chat at https://kotlinlang.slack.com](https://img.shields.io/badge/slack-@kotlinlang/ktlint-yellow.svg?logo=slack)](https://kotlinlang.slack.com/messages/CKS3XG0LS)
Expand Down Expand Up @@ -198,7 +199,7 @@ Plugin supports KtLint baseline with following limitations:
- One baseline file is generated per one Gradle project (module).

Run task `ktlintGenerateBaseline` to generate a new baseline.

#### Testing KtLint snapshots

To test KtLint snapshots add following configuration into project build script (latest KtLint snapshot version name
Expand Down
14 changes: 14 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Releasing

How to perform a release of the plugin.

1. Update the `CHANGELOG.md` and `VERSION.txt` file by running the
[Prepare for Release](https://github.com/JLLeitschuh/ktlint-gradle/actions/workflows/prepare-release.yaml)
GitHub action.
2. Verify that the [CHANGELOG.md](https://github.com/JLLeitschuh/ktlint-gradle/blob/master/CHANGELOG.md) file looks good.

**NOTE**: The `## [Unreleased]` header should still remain in the document, but should be empty.
This is expected by the GitHub release note upload step.
3. Run the
[Perform Release](https://github.com/JLLeitschuh/ktlint-gradle/actions/workflows/perform-release.yaml) GitHub action.
This will actually perform the release.
1 change: 1 addition & 0 deletions plugin/VERSION_CURRENT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.3.0-SNAPSHOT
1 change: 1 addition & 0 deletions plugin/VERSION_LATEST_RELEASE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.2.1
7 changes: 4 additions & 3 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ plugins {

val pluginGroup = "org.jlleitschuh.gradle"
group = pluginGroup
version = "10.3.0-SNAPSHOT"
version = projectDir.resolve("VERSION_CURRENT.txt").readText().trim()

repositories {
google()
Expand Down Expand Up @@ -241,9 +241,10 @@ githubRelease {
body {
projectDir.resolve("../CHANGELOG.md")
.readText()
.substringAfter("## ")
.substringAfter("## [")
.substringAfter("## [")
.substringBefore("## [")
.prefixIfNot("## ")
.prefixIfNot("## [")
}
}

Expand Down
3 changes: 2 additions & 1 deletion plugin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
pluginManagement {
val latestRelease = file("VERSION_LATEST_RELEASE.txt").readText().trim()
plugins {
id("org.jlleitschuh.gradle.ktlint") version latestRelease
id("org.jetbrains.kotlin.jvm") version "1.5.21"
id("com.gradle.plugin-publish") version "0.15.0"
`java-gradle-plugin`
`maven-publish`
id("org.jlleitschuh.gradle.ktlint") version "10.2.1"
id("com.github.johnrengelman.shadow") version "7.0.0"
id("com.github.breadmoirai.github-release") version "2.2.10"
}
Expand Down

0 comments on commit 8e542fd

Please sign in to comment.