fixed rubocop in workflow #4
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: Validate and Publish | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| id-token: write # required for RubyGems trusted publishing (OIDC) | |
| jobs: | |
| build: | |
| if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/v') | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.extract-version.outputs.version }} | |
| steps: | |
| # https://github.com/actions/checkout | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Extract and validate version from branch name | |
| id: extract-version | |
| run: | | |
| VERSION="${GITHUB_HEAD_REF#release/}" | |
| if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "::error::Branch name does not match expected format release/vX.X.X (got: $GITHUB_HEAD_REF)" | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Extracted version: $VERSION" | |
| # https://github.com/ruby/setup-ruby | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@80740b3b13bf9857e28854481ca95a84e78a2bdf # v1.284.0 | |
| with: | |
| ruby-version: '3.3' | |
| bundler-cache: true | |
| working-directory: turnkey_client | |
| - name: Install rubocop | |
| run: gem install rubocop | |
| - name: Run rubocop | |
| run: rubocop | |
| - name: Validate gem builds | |
| working-directory: turnkey_client | |
| run: gem build turnkey_client.gemspec | |
| prepare-release: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| # https://github.com/actions/checkout | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2.2.2 | |
| with: | |
| tag_name: ${{ needs.build.outputs.version }} | |
| name: Release ${{ needs.build.outputs.version }} | |
| generate_release_notes: true | |
| draft: true | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish: | |
| needs: prepare-release | |
| runs-on: | |
| group: package-deploy | |
| environment: production # require manual approval for production deployments | |
| permissions: | |
| contents: write | |
| id-token: write # required for RubyGems trusted publishing (OIDC) | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@80740b3b13bf9857e28854481ca95a84e78a2bdf # v1.284.0 | |
| with: | |
| ruby-version: '3.3' | |
| bundler-cache: true | |
| working-directory: turnkey_client | |
| # OIDC trusted publishing | |
| # Uses the same credentials action as rubygems/release-gem | |
| - name: Configure trusted publishing credentials | |
| uses: rubygems/configure-rubygems-credentials@bc6dd217f8a4f919d6835fcfefd470ef821f5c44 # v1.0.0 | |
| - name: Build gem | |
| working-directory: turnkey_client | |
| run: | | |
| gem build turnkey_client.gemspec | |
| echo "Built gem:" | |
| ls -la *.gem | |
| - name: Publish to RubyGems | |
| working-directory: turnkey_client | |
| run: | | |
| echo "Publishing to RubyGems..." | |
| gem push turnkey_client-*.gem || { | |
| echo "Publish failed. Check logs above."; | |
| exit 1; | |
| } | |
| echo "Successfully published to RubyGems" | |
| - name: Wait for release to propagate | |
| working-directory: turnkey_client | |
| run: gem exec rubygems-await *.gem |