Cleanup after 1.7.2 release (#3204)

* Revert "Master 1.7.x release on master (#3203)"

This reverts commit 33aef59c68ef8d56d29c128fa494df86be6c1585.

* Revert "Restrict publish release build to 1.7.2 on master-1.7.x branch (#3202)"

This reverts commit 9b296eadeb02c3a403acb37480baa700281312fb.

* Revert "Temporarily change publish release build flow to release version 1.7.2 while 1.8.0 is already released. (#3201)"

This reverts commit 2eea5c56eeaddc3bf8ab3bbc44430673cf05d366.

* Document how to release a patch version on an older minor release
diff --git a/.github/workflows/publish-release-build.yml b/.github/workflows/publish-release-build.yml
index 26f5061..0d9cb64 100644
--- a/.github/workflows/publish-release-build.yml
+++ b/.github/workflows/publish-release-build.yml
@@ -5,7 +5,7 @@
 on:
   push:
     tags:
-      - '1.7.2'
+      - '*.*.*'
 
 jobs:
   publish:
@@ -15,11 +15,11 @@
     steps:
       - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
         with:
-          ref: 'master-1.7.x'
+          ref: 'master'
 
       - uses: ./.github/actions/setup-gradle-build
 
-      - name: Build executable and publish to Maven - from master workflow on master-1.7.x branch
+      - name: Build executable and publish to Maven
         run: ./gradlew clean ktlintCliFiles publishMavenPublicationToMavenCentralRepository
         env:
           ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.CENTRAL_PORTAL_USERNAME }}
@@ -28,63 +28,63 @@
           ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEYID }}
           ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}
 
-#      - name: Validate changelog.md
-#        id: validate_changelog
-#        if: ${{ success() }}
-#        run: |
-#          FIRST_HEADING2=$(grep "^## " CHANGELOG.md | head -n 1)
-#          echo "First heading2 found: $FIRST_HEADING2"
-#          if [[ ! "$FIRST_HEADING2" =~ ^##[[:space:]]\[[0-9]+\.[0-9]+\.[0-9]+\][[:space:]]-[[:space:]][0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
-#            echo "First heading at level 2 should match '## [X.Y.Z] - [YYYY-MM-DD]'"
-#            exit 1
-#          fi
+      - name: Validate changelog.md
+        id: validate_changelog
+        if: ${{ success() }}
+        run: |
+          FIRST_HEADING2=$(grep "^## " CHANGELOG.md | head -n 1)
+          echo "First heading2 found: $FIRST_HEADING2"
+          if [[ ! "$FIRST_HEADING2" =~ ^##[[:space:]]\[[0-9]+\.[0-9]+\.[0-9]+\][[:space:]]-[[:space:]][0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
+            echo "First heading at level 2 should match '## [X.Y.Z] - [YYYY-MM-DD]'"
+            exit 1
+          fi
 
-#      - name: Extract release notes
-#        id: release_notes
-#        if: ${{ success() }}
-#        uses: ffurrer2/extract-release-notes@v2
+      - name: Extract release notes
+        id: release_notes
+        if: ${{ success() }}
+        uses: ffurrer2/extract-release-notes@v2
 
-#      - name: Get version
-#        id: get_version
-#        if: ${{ success() }}
-#        run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
+      - name: Get version
+        id: get_version
+        if: ${{ success() }}
+        run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
 
-#      - name: Create zip for dependency manager(s)
-#        if: ${{ success() }}
-#        run: |
-#          cd ktlint-cli/build/run
-#          mkdir -p ktlint-${{ env.version }}/bin
-#          cp ktlint ktlint-${{ env.version }}/bin
-#          zip -rm ktlint-${{ env.version }}.zip ktlint-${{ env.version }}
+      - name: Create zip for dependency manager(s)
+        if: ${{ success() }}
+        run: |
+          cd ktlint-cli/build/run
+          mkdir -p ktlint-${{ env.version }}/bin
+          cp ktlint ktlint-${{ env.version }}/bin
+          zip -rm ktlint-${{ env.version }}.zip ktlint-${{ env.version }}
 
-#      - name: Create release
-#        id: github_release
-#        if: ${{ success() }}
-#        uses: softprops/action-gh-release@v2
-#        with:
-#          draft: false
-#          prerelease: false
-#          body: ${{ steps.release_notes.outputs.release_notes }}
-#          files: |
-#            ktlint-cli/build/run/*
-#        env:
-#          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+      - name: Create release
+        id: github_release
+        if: ${{ success() }}
+        uses: softprops/action-gh-release@v2
+        with:
+          draft: false
+          prerelease: false
+          body: ${{ steps.release_notes.outputs.release_notes }}
+          files: |
+            ktlint-cli/build/run/*
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
-#      - name: Bump Homebrew Formula
-#        if: ${{ success() }}
-#        uses: mislav/bump-homebrew-formula-action@v2
-#        env:
-#          COMMITTER_TOKEN: ${{ secrets.HOMEBREW_TOKEN }}
-#        with:
-#          formula-name: ktlint
-#          formula-path: Formula/k/ktlint.rb
-#          download-url: https://github.com/pinterest/ktlint/releases/download/${{ env.version }}/ktlint-${{ env.version }}.zip
+      - name: Bump Homebrew Formula
+        if: ${{ success() }}
+        uses: mislav/bump-homebrew-formula-action@v2
+        env:
+          COMMITTER_TOKEN: ${{ secrets.HOMEBREW_TOKEN }}
+        with:
+          formula-name: ktlint
+          formula-path: Formula/k/ktlint.rb
+          download-url: https://github.com/pinterest/ktlint/releases/download/${{ env.version }}/ktlint-${{ env.version }}.zip
 
-#      - name: Update Release documentation
-#        if: ${{ success() }}
-#        run: |
-#          git config user.email "ktlint@github.com"
-#          git config user.name "Ktlint Release Workflow" |
-#          ./.announce -y
-#        env:
-#          VERSION: ${{ env.version }}
+      - name: Update Release documentation
+        if: ${{ success() }}
+        run: |
+          git config user.email "ktlint@github.com"
+          git config user.name "Ktlint Release Workflow" |
+          ./.announce -y
+        env:
+          VERSION: ${{ env.version }}
diff --git a/RELEASING.md b/RELEASING.md
index 5148f8f..0d13622 100644
--- a/RELEASING.md
+++ b/RELEASING.md
@@ -22,3 +22,32 @@
 13. Verify that the published documentation does not contain broken links with [Broken Link Checker Tool](https://www.deadlinkchecker.com/website-dead-link-checker.asp).
 14. Announce release on Ktlint Slack channel but wait with doing so until sonatype release is closed by Pinterest.
 15. Update `gradle.properties` with the new `SNAPSHOT` version
+
+## Creating a patch release for an older minor version
+
+Sometimes it can happen that after a minor release, it is required to release a patch version on an older minor version as well. For example after releasing ktlint `1.8.0` and Ktlint IntelliJ Plugin `0.30.x` it turned out that starting from that version the `1.7.0` and `1.7.1` are no longer compatible with the plugin version `0.30` and above. This is blocking issue for users who can not upgrade from ktlint `1.7.x` to `1.8.x` or higher.
+
+For problem above, the following steps resulted in a new `1.7.2` release being published on Maven after `1.8.0` was released:
+* Create branch `master-1.7.x` from tag `1.7.1`
+  * Via cherry-picking add commits to the branch that need to be published in the `1.7.2` release.
+  * Push the branch. Do not create a merge request as this branch is not going to be merged into master.
+* On normal `master` branch change the `publish-release-build.yml` file as follows:
+  * Restrict the tag that is accepted for this release:
+    ```yaml
+    on:
+      push:
+        tags:
+          - '1.7.2'
+    ```
+  * Change the reference in the `actions/checkout`:
+    ```yaml
+      - uses: actions/checkout
+        with:
+          ref: 'master-1.7.x'
+    ```
+  * Comment out all steps (except publication to Maven Central).
+  * Push the branch, and merge to master.
+  * Like normal, add a tag with the new release version, and push it directly to remote (e.g. `git tag 1.7.2 && git push origin 1.7.2`). This will kick off the [Release workflow](https://github.com/pinterest/ktlint/actions/workflows/publish-release-build.yml). Important: when you get an error like `HttpError: refusing to allow a Personal Access Token to create or update workflow '.github/workflows/automerge-triggers.yml' without 'workflow' scope`, the GitHub personal access token is most likely expired. When this happens on the bump of the Homebrew formula, the personal access token of @shashachu needs to be updated.
+  * Close and release the repo on Sonatype. Only Pinterest employees can do this. Wait with steps below until artifacts are published on https://central.sonatype.com/search?q=com.pinterest.ktlint&sort=published
+  * Revert the changes in `publish-release-build.yml`. Push the branch, and merge to master.
+