name: Push Gem

on:
  push:
    tags:
      - v*

permissions:
  contents: read

jobs:
  push:
    if: github.repository == 'ViewComponent/view_component'
    runs-on: ubuntu-latest

    permissions:
      contents: write
      id-token: write

    # GitHub environment configured on RubyGems
    environment: release

    steps:
      # Set up
      - name: Harden Runner
        uses: step-security/harden-runner@v2
        with:
          egress-policy: audit

      - uses: actions/checkout@v4
      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
          ruby-version: 4.0

      # Release
      - uses: rubygems/release-gem@v1
