diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..488a028 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +--- +name: Release Gem +description: | + This workflow creates a new release on GitHub and publishes the gem to + RubyGems.org. + + The workflow uses the `googleapis/release-please-action` to handle the + release creation process and the `rubygems/release-gem` action to publish + the gem. + +on: + push: + branches: ["main"] + + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + + environment: + name: RubyGems + url: https://rubygems.org/gems/github_pages_rake_tasks + + permissions: + contents: write + pull-requests: write + id-token: write + + steps: + - name: Checkout project + uses: actions/checkout@v4 + + - name: Create release + uses: googleapis/release-please-action@v4 + id: release + with: + token: ${{ secrets.AUTO_RELEASE_TOKEN }} + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + + - name: Setup ruby + uses: ruby/setup-ruby@v1 + if: ${{ steps.release.outputs.release_created }} + with: + bundler-cache: true + ruby-version: ruby + + - name: Push to RubyGems.org + uses: rubygems/release-gem@v1 + if: ${{ steps.release.outputs.release_created }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..8d7e5f1 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.0.1" +} diff --git a/Rakefile b/Rakefile index 6f9193c..9fe9c46 100644 --- a/Rakefile +++ b/Rakefile @@ -26,6 +26,13 @@ rescue Bundler::BundlerError => e exit e.status_code end +# Make it so that calling `rake release` just calls `rake release:rubygems_push` to +# avoid creating and pushing a new tag. + +Rake::Task['release'].clear +desc 'Customized release task to avoid creating a new tag' +task release: 'release:rubygem_push' + CLEAN << 'pkg' CLEAN << 'Gemfile.lock' diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..0d4396f --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,22 @@ +{ + "bootstrap-sha": "63e60714532721c2f407d6c15d7f80d4b3062db8", + "packages": { + ".": { + "release-type": "ruby", + "package-name": "github_pages_rake_tasks", + "changelog-path": "CHANGELOG.md", + "version-file": "lib/github_pages_rake_tasks/version.rb", + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": true, + "draft": false, + "prerelease": false, + "include-component-in-tag": false + } + }, + "plugins": [ + { + "type": "sentence-case" + } + ], + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" +}