diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml deleted file mode 100644 index 10798c8..0000000 --- a/.github/workflows/post-release.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Post-release SNAPSHOT Bump - -on: - release: - types: [published] - -permissions: - contents: write - pull-requests: write - -jobs: - bump-snapshot: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - with: - persist-credentials: true # required: this workflow pushes a branch - - - name: Calculate next SNAPSHOT version - id: next - run: | - version=$(grep "^version=" gradle.properties | cut -d'=' -f2) - IFS='.' read -r major minor patch <<< "$version" - next_patch=$((patch + 1)) - snapshot="${major}.${minor}.${next_patch}-SNAPSHOT" - echo "snapshot=${snapshot}" >> "$GITHUB_OUTPUT" - - - name: Bump version in gradle.properties - env: - SNAPSHOT: ${{ steps.next.outputs.snapshot }} - run: | - sed -i "s/^version=.*/version=${SNAPSHOT}/" gradle.properties - - - name: Create pull request - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SNAPSHOT: ${{ steps.next.outputs.snapshot }} - run: | - branch="chore/next-snapshot-${SNAPSHOT}" - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git checkout -b "${branch}" - git add gradle.properties - git commit -m "chore: prepare next development version ${SNAPSHOT}" - git push origin "${branch}" - gh pr create \ - --title "chore: prepare next development version ${SNAPSHOT}" \ - --body "Automated PR to bump version to next development SNAPSHOT after release." \ - --label release diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index bfbeac5..49cc8eb 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -13,5 +13,40 @@ jobs: runs-on: ubuntu-latest steps: - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5 + id: release with: token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + if: ${{ steps.release.outputs.release_created }} + with: + persist-credentials: true + + - name: Calculate next SNAPSHOT version + id: next + if: ${{ steps.release.outputs.release_created }} + env: + MAJOR: ${{ steps.release.outputs.major }} + MINOR: ${{ steps.release.outputs.minor }} + PATCH: ${{ steps.release.outputs.patch }} + run: | + next_patch=$(( PATCH + 1 )) + echo "snapshot=${MAJOR}.${MINOR}.${next_patch}-SNAPSHOT" >> "$GITHUB_OUTPUT" + + - name: Bump version to next SNAPSHOT + if: ${{ steps.release.outputs.release_created }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SNAPSHOT: ${{ steps.next.outputs.snapshot }} + run: | + branch="chore/next-snapshot-${SNAPSHOT}" + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git checkout -b "${branch}" + sed -i "s/^detektExtensionVersion=.*/detektExtensionVersion=${SNAPSHOT}/" gradle.properties + git add gradle.properties + git commit -m "chore: prepare next development version ${SNAPSHOT}" + git push origin "${branch}" + gh pr create \ + --title "chore: prepare next development version ${SNAPSHOT}" \ + --body "Automated PR to bump version to next development SNAPSHOT after release." diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 29f3cb9..5bac37e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -87,5 +87,16 @@ Merges are always fast-forward. The merged branch should be deleted at the time Merge commits are reserved for forward-merging release branches that have received patches. +## Release Process + +Releases are automated via [release-please](https://github.com/googleapis/release-please): + +1. Merge conventional commits to `main` +2. release-please opens or updates a release PR (bumps version in `gradle.properties`) +3. Maintainer reviews and merges the release PR +4. release-please creates a semver tag and GitHub Release with auto-generated notes +5. The publish workflow publishes the release to Maven Central +6. A follow-up PR is automatically created to bump to the next SNAPSHOT version + ## Conversation Please file issues for this extension under github issues. diff --git a/gradle.properties b/gradle.properties index 1575275..bd9ad1d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,9 @@ org.gradle.caching=true org.gradle.jvmargs=-Dfile.encoding=UTF-8 kotlin.code.style=official +# x-release-please-start-version detektExtensionVersion=2.2.0-SNAPSHOT +# x-release-please-end POM_NAME=Detekt Extensions POM_DESCRIPTION=A Detekt Extension Library diff --git a/release-please-config.json b/release-please-config.json index bc14414..a298150 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -4,24 +4,15 @@ "include-component-in-tag": false, "tag-separator": "", "bump-patch-for-minor-pre-major": false, - "changelog-sections": [ - {"type": "feat", "section": "### Added"}, - {"type": "fix", "section": "### Fixed"}, - {"type": "deps", "section": "### Changed"}, - {"type": "chore", "section": "### Changed", "hidden": false} - ], - "extra-files": [ - { - "type": "generic", - "path": "gradle.properties", - "search": "detektExtensionVersion=\\d+\\.\\d+\\.\\d+(-SNAPSHOT)?", - "replace": "detektExtensionVersion={{version}}" - } - ], - "packages": { - ".": { - "tag-prefix": "", - "generate-release-notes": true + "packages": { + ".": { + "tag-prefix": "", + "extra-files": [ + { + "type": "generic", + "path": "gradle.properties" } + ] } + } }