diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ec05db10..a84d4c09 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -12,7 +12,10 @@ What changed in this PR? ## Pre-merge checklist * [ ] Update relevant READMEs -* [ ] Run `bin/bump_version` or `bin/bump_version --patch` + +## Notes + +Please don't commit version changes within your PR. Versioning is managed through the GitHub Workflow. ## Screenshots diff --git a/.github/workflows/bump_version.yml b/.github/workflows/bump_version.yml new file mode 100644 index 00000000..031e1b8f --- /dev/null +++ b/.github/workflows/bump_version.yml @@ -0,0 +1,41 @@ +name: Bump Version & Publish a GitHub Release + +on: + workflow_dispatch: + inputs: + bump-type: + description: SemVer Bump Type (minor by default) + required: false + type: choice + options: + - --patch + - --major + +permissions: + contents: write + +jobs: + push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: ruby/setup-ruby@v1 + with: { bundler-cache: true } + + - name: Bump, commit, and tag version + id: bump_version + run: | + set -euo pipefail + bin/bump_version ${{ github.event.inputs['bump-type'] }} + + version="$(ruby -e "require './lib/rolemodel/version'; puts Rolemodel::VERSION")" + tag_name="v${version}" + + git config user.name 'github-actions[bot]' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + + git add . + git commit -m "${tag_name}" + git tag "${tag_name}" + + git push origin "HEAD:${GITHUB_REF_NAME}" --follow-tags diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cac899a4..78e2d1ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ concurrency: jobs: run_specs: name: Rspec - runs-on: blacksmith-4vcpu-ubuntu-2404 + runs-on: ubuntu-latest timeout-minutes: 10 env: CI: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..3fe2467d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +name: Create GitHub Release & Publish gem to rubygems.org + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + id-token: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Create GitHub release + run: | + tag_name="$(git describe --tags --abbrev=0)" + gh release create "${tag_name}" --verify-tag --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: { persist-credentials: false } + - uses: ruby/setup-ruby@v1 + with: { bundler-cache: true } + - uses: rubygems/release-gem@v1 diff --git a/bin/bump_version b/bin/bump_version index b5f991e2..5e1433ac 100755 --- a/bin/bump_version +++ b/bin/bump_version @@ -24,10 +24,6 @@ class VersionBumper < Thor::Group run_clean_bundle_install end - def build_gem - run 'gem build rolemodel-rails.gemspec' - end - def update_current_example_app Rake::FileList.new('example_rails_*').each do |example_path| inside(example_path) do