Revert "Remove JRuby 9.4 from CI matrix" #3
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: Build gem | |
| on: # yamllint disable-line rule:truthy | |
| workflow_dispatch: | |
| inputs: | |
| push: | |
| description: Push gem | |
| required: true | |
| type: boolean | |
| default: true | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| # Default permissions for all jobs | |
| permissions: {} | |
| env: | |
| GEM_HOST: "https://rubygems.pkg.github.com/DataDog" | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| type: | |
| - final | |
| - dev | |
| runs-on: ubuntu-24.04 | |
| name: Build gem (${{ matrix.type }}) | |
| env: | |
| BUNDLE_GEMFILE: gemfiles/ruby-4.0.gemfile | |
| BUNDLE_FROZEN: "true" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: ruby/setup-ruby@a30dfa457ad68707b8b910ac3a244714b61c0626 # v1.320.0 | |
| with: | |
| ruby-version: "4.0.1" | |
| bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
| - name: Patch version | |
| if: ${{ matrix.type != 'final' }} | |
| env: | |
| GHA_RUN_ID: ${{ github.run_id }} | |
| GIT_REF: ${{ github.ref }} | |
| GIT_SHA: ${{ github.sha }} | |
| run: | | |
| .gitlab/patch_gem_version.sh gha "$GHA_RUN_ID" "$GIT_REF" "$GIT_SHA"; | |
| - name: Patch gem host | |
| if: ${{ matrix.type != 'final' }} | |
| run: | | |
| # Patch in GEM_HOST | |
| sed datadog.gemspec -i -e "s,^\([\t ]*spec\.metadata\['allowed_push_host'\]\) *= *,\1 = \'${GEM_HOST}\' # ," | |
| # Test result | |
| grep -e allowed_push_host datadog.gemspec | |
| - name: Build gem | |
| env: | |
| BUNDLE_FROZEN: "false" | |
| run: bundle exec rake build | |
| - name: List gem | |
| run: | | |
| find pkg | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: "datadog-gem-${{ matrix.type }}-gha${{ github.run_id }}-g${{ github.sha }}" | |
| path: "pkg/*.gem" | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| type: | |
| - final | |
| - dev | |
| runs-on: ubuntu-24.04 | |
| name: Test gem | |
| needs: | |
| - build | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: "datadog-gem-${{ matrix.type }}-gha${{ github.run_id }}-g${{ github.sha }}" | |
| path: "pkg" | |
| - name: List gem | |
| run: | | |
| find pkg | |
| - uses: ruby/setup-ruby@a30dfa457ad68707b8b910ac3a244714b61c0626 # v1.320.0 | |
| with: | |
| ruby-version: "4.0.1" | |
| - name: Install gem | |
| # zizmor: ignore[adhoc-packages] installs the artifact just built by this workflow, not an external dependency | |
| run: | | |
| gem install pkg/*.gem | |
| push: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| type: | |
| - dev | |
| runs-on: ubuntu-24.04 | |
| name: Push gem | |
| needs: | |
| - test | |
| if: ${{ inputs.push }} | |
| permissions: | |
| id-token: write | |
| packages: write | |
| steps: | |
| - name: Download artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: "datadog-gem-${{ matrix.type }}-gha${{ github.run_id }}-g${{ github.sha }}" | |
| path: "pkg" | |
| - name: List gem | |
| run: | | |
| find pkg | |
| - name: Get GitHub Token via dd-octo-sts | |
| id: generate-token | |
| uses: DataDog/dd-octo-sts-action@96a25462dbcb10ebf0bfd6e2ccc917d2ab235b9a # v1.0.4 | |
| with: | |
| scope: DataDog/dd-trace-rb | |
| policy: self.build-gem | |
| - name: Set up GitHub Packages authentication | |
| run: | | |
| mkdir -p ~/.gem | |
| cat > ~/.gem/credentials <<'CREDENTIALS' | |
| --- | |
| :github: Bearer ${{ steps.generate-token.outputs.token }} | |
| CREDENTIALS | |
| chmod 0600 ~/.gem/credentials | |
| - name: Push gem | |
| run: | | |
| find pkg -name '*.gem' | while read -r gem; do | |
| echo "=== pushing '${gem}'" | |
| gem push --key github --host ${{ env.GEM_HOST }} "${gem}" | |
| done | |
| - name: Clean up credentials | |
| run: | | |
| rm -rvf ~/.gem/credentials | |
| complete: | |
| name: Build Gem (complete) | |
| runs-on: ubuntu-24.04 | |
| needs: | |
| - test | |
| steps: | |
| - run: echo "DONE!" |