diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..1891179 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,56 @@ +name: release-please + +# Keeps one open release pull request that collects the Conventional Commits +# merged since the last release into CHANGELOG.md and picks the next version. +# Merging it pushes the vX.Y.Z tag and a draft GitHub release; the tag starts +# release.yml, which publishes the gem to RubyGems.org and then publishes +# the GitHub release. +# +# Needs the organization's release bot GitHub App, because tags and pull +# requests made with the workflow's own GITHUB_TOKEN do not start other +# workflows: +# variable RELEASE_BOT_APP_ID (or RELEASE_BOT_CLIENT_ID) and +# secret RELEASE_BOT_PRIVATE_KEY. +"on": + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: release-please + cancel-in-progress: false + +jobs: + release-please: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Check the release bot is set up + id: bot + env: + APP_ID: ${{ vars.RELEASE_BOT_APP_ID }} + CLIENT_ID: ${{ vars.RELEASE_BOT_CLIENT_ID }} + HAS_KEY: ${{ secrets.RELEASE_BOT_PRIVATE_KEY != '' }} + run: | + if { [ -n "${APP_ID}" ] || [ -n "${CLIENT_ID}" ]; } && [ "${HAS_KEY}" = "true" ]; then + echo "ready=true" >> "$GITHUB_OUTPUT" + else + echo "::warning title=release-please skipped::Set the variable RELEASE_BOT_APP_ID and secret RELEASE_BOT_PRIVATE_KEY (see CONTRIBUTING.md, Releases)." + echo "ready=false" >> "$GITHUB_OUTPUT" + fi + - uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0 + if: steps.bot.outputs.ready == 'true' + id: app + with: + # GitHub accepts either the App ID or the Client ID here. + client-id: ${{ vars.RELEASE_BOT_CLIENT_ID || vars.RELEASE_BOT_APP_ID }} + private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} + - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0 + if: steps.bot.outputs.ready == 'true' + with: + token: ${{ steps.app.outputs.token }} + config-file: release-please-config.json + manifest-file: .release-please-manifest.json diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..b881a39 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1 @@ +{".":"0.1.0"} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 87cde35..60bf759 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,11 +20,18 @@ Please report security problems privately as described in [SECURITY.md](SECURITY ## Releases -Push a `vX.Y.Z` tag that matches `KnifeNoderings::VERSION` (or merge the -release-please pull request once that workflow is in place). The tag starts -`.github/workflows/release.yml`, which publishes the gem to -[RubyGems.org](https://rubygems.org/gems/knife-noderings) with trusted -publishing and then publishes the GitHub release. +1. Merge pull requests into `main`. release-please + (`.github/workflows/release-please.yml`, using the noderings-release-bot GitHub App) + keeps a pull request named `chore: release X.Y.Z` up to date. It changes + the version in `lib/knife-noderings/version.rb` and writes `CHANGELOG.md`. +2. Merge that pull request when you want to release. release-please pushes the tag + `vX.Y.Z` and creates a draft GitHub release. +3. The tag starts `.github/workflows/release.yml`, which publishes the gem to + [RubyGems.org](https://rubygems.org/gems/knife-noderings) with trusted + publishing, then publishes the GitHub release. + +Do not create tags or releases by hand. A gem version on RubyGems.org cannot be +replaced, so only merge the release pull request when you mean to publish. The first push of a new gem must pass the RubyGems.org account ID (`owner: "256963"`) when exchanging the OIDC token, as already set in `release.yml`. To retry a diff --git a/lib/knife-noderings/version.rb b/lib/knife-noderings/version.rb index 29f31bc..4fce9cb 100644 --- a/lib/knife-noderings/version.rb +++ b/lib/knife-noderings/version.rb @@ -6,5 +6,5 @@ # module KnifeNoderings - VERSION = "0.1.0" + VERSION = "0.1.0" # x-release-please-version end diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..220083b --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,70 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "release-type": "simple", + "include-v-in-tag": true, + "include-component-in-tag": false, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "draft": true, + "force-tag-creation": true, + "pull-request-title-pattern": "chore: release ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance" + }, + { + "type": "deps", + "section": "Dependencies" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "refactor", + "section": "Other", + "hidden": true + }, + { + "type": "chore", + "section": "Other", + "hidden": true + }, + { + "type": "ci", + "section": "Other", + "hidden": true + }, + { + "type": "test", + "section": "Other", + "hidden": true + }, + { + "type": "build", + "section": "Other", + "hidden": true + } + ], + "packages": { + ".": { + "package-name": "knife-noderings", + "changelog-path": "CHANGELOG.md", + "extra-files": [ + { + "type": "generic", + "path": "lib/knife-noderings/version.rb" + } + ] + } + } +}