Repository navigation
Release #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Release version (e.g., 1.12.0)" | |
| required: true | |
| type: string | |
| jobs: | |
| release: | |
| name: Release v${{ github.event.inputs.version }} | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| permissions: | |
| id-token: write | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: ./.github/actions/setup-ruby-and-dependencies | |
| with: | |
| ruby-version: "4.0" | |
| cache-apt-packages: true | |
| - name: Verify version | |
| run: | | |
| GEM_VERSION="${{ github.event.inputs.version }}" | |
| CODE_VERSION=$(ruby -I lib -r capybara/screenshot/diff/version -e "puts Capybara::Screenshot::Diff::VERSION") | |
| if [ "$GEM_VERSION" != "$CODE_VERSION" ]; then | |
| echo "Version mismatch: input=$GEM_VERSION code=$CODE_VERSION" | |
| exit 1 | |
| fi | |
| - name: Test | |
| run: bundle exec rake test:unit | |
| # Idempotent so a failed run can be re-dispatched (bit us at beta1): | |
| # skip when the tag already exists at HEAD, fail loudly if it exists | |
| # at a different commit -- never retag. | |
| - name: Create tag | |
| run: | | |
| TAG="v${{ github.event.inputs.version }}" | |
| # checkout doesn't fetch tags; pull this one if it exists remotely. | |
| git fetch --force origin "refs/tags/$TAG:refs/tags/$TAG" 2>/dev/null || true | |
| if EXISTING=$(git rev-parse -q --verify "refs/tags/$TAG^{commit}"); then | |
| if [ "$EXISTING" = "$(git rev-parse HEAD)" ]; then | |
| echo "Tag $TAG already exists at HEAD; skipping tag creation." | |
| else | |
| echo "::error::Tag $TAG already exists at $EXISTING, but HEAD is $(git rev-parse HEAD). Refusing to retag." | |
| exit 1 | |
| fi | |
| else | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "$TAG" -m "$TAG" | |
| git push origin "$TAG" | |
| fi | |
| - name: Publish to RubyGems | |
| uses: rubygems/release-gem@v1 | |
| # Mirror release: the same content ships under the forward-looking gem | |
| # name snap_diff-capybara with an identical version. The mirror gemspec | |
| # is generated here (not committed) so local `gem build` and the | |
| # Gemfile's `gemspec` directive stay unambiguous. Requires the | |
| # snap_diff-capybara gem on rubygems.org to trust this repo+workflow | |
| # as a trusted publisher. | |
| # No separate credential setup: release-gem above already configured | |
| # trusted-publishing credentials, and the temporary key covers any gem | |
| # whose rubygems.org settings trust this repo+workflow. | |
| - name: Publish snap_diff-capybara mirror to RubyGems | |
| run: | | |
| ruby -e ' | |
| spec = Gem::Specification.load("capybara-screenshot-diff.gemspec") | |
| spec.name = "snap_diff-capybara" | |
| File.write("snap_diff-capybara.gemspec", spec.to_ruby) | |
| ' | |
| gem build snap_diff-capybara.gemspec | |
| gem push "snap_diff-capybara-${{ github.event.inputs.version }}.gem" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: "v${{ github.event.inputs.version }}" | |
| name: "v${{ github.event.inputs.version }}" | |
| body: | | |
| ## What's Changed | |
| See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/v${{ github.event.inputs.version }}/CHANGELOG.md) for full details. | |
| **Upgrade Guide:** [docs/UPGRADING.md](https://github.com/${{ github.repository }}/blob/v${{ github.event.inputs.version }}/docs/UPGRADING.md) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |