From f37aef27274de4c71c8b3fe8f797002855f0dd82 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Feb 2026 10:25:08 +0000 Subject: [PATCH 1/2] Add GitHub Actions workflows for CI and RubyGems publishing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CI: runs tests across Ruby 3.0–3.3 on every push/PR to main - Release: builds and publishes gem to RubyGems on version tags (v*) using trusted publishing (OIDC, no API key secret needed) https://claude.ai/code/session_01CvCNpdSjh1STBdmS9n5DN9 --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e11165a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: ["3.0", "3.1", "3.2", "3.3"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby ${{ matrix.ruby-version }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + + - name: Run tests + run: ruby -Ilib -Itest -e "Dir['test/test_*.rb'].each { |f| require_relative f }" + + - name: Verify gem builds + run: gem build ipdata.gemspec diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7e8f2fe --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +name: Publish to RubyGems + +on: + push: + tags: + - "v*" + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.3" + + - name: Run tests + run: ruby -Ilib -Itest -e "Dir['test/test_*.rb'].each { |f| require_relative f }" + + - name: Build gem + run: gem build ipdata.gemspec + + - name: Push to RubyGems + uses: rubygems/release-gem@v1 From be6c17dbadb02f0c4ba565a25d8232e84c916945 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Feb 2026 10:26:43 +0000 Subject: [PATCH 2/2] Add automated version bump and release via workflow_dispatch The release workflow now supports two triggers: - Push a v* tag manually (existing behavior) - Click "Run workflow" in GitHub Actions UI, pick patch/minor/major, and it automatically bumps version.rb, commits, tags, and publishes https://claude.ai/code/session_01CvCNpdSjh1STBdmS9n5DN9 --- .github/workflows/release.yml | 56 +++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7e8f2fe..8318d1f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,64 @@ -# frozen_string_literal: true - name: Publish to RubyGems on: push: tags: - "v*" + workflow_dispatch: + inputs: + bump: + description: "Version bump type" + required: true + type: choice + options: + - patch + - minor + - major jobs: + bump: + if: github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.3" + + - name: Bump version + id: bump + run: | + current=$(ruby -r ./lib/ipdata/version -e "puts IPData::VERSION") + IFS='.' read -r major minor patch <<< "$current" + + case "${{ inputs.bump }}" in + major) major=$((major + 1)); minor=0; patch=0 ;; + minor) minor=$((minor + 1)); patch=0 ;; + patch) patch=$((patch + 1)) ;; + esac + + new_version="${major}.${minor}.${patch}" + echo "version=${new_version}" >> "$GITHUB_OUTPUT" + + sed -i "s/VERSION = \"${current}\"/VERSION = \"${new_version}\"/" lib/ipdata/version.rb + + - name: Commit and tag + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add lib/ipdata/version.rb + git commit -m "Bump version to v${{ steps.bump.outputs.version }}" + git tag "v${{ steps.bump.outputs.version }}" + git push origin main --tags + release: + if: always() && (github.event_name == 'push' || needs.bump.result == 'success') + needs: [bump] runs-on: ubuntu-latest permissions: contents: read @@ -16,6 +66,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + ref: ${{ github.event_name == 'workflow_dispatch' && 'main' || github.ref }} - name: Set up Ruby uses: ruby/setup-ruby@v1