ci #17
Workflow file for this run
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: ci | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ["v*"] | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| ruby-version: ["3.1", "3.4"] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: oxidize-rb/actions/setup-ruby-and-rust@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| - run: bundle exec rake | |
| - run: cargo fmt --check | |
| - run: cargo clippy --workspace --all-features --locked -- -D warnings | |
| native-gems: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: test | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| artifact: x86_64-linux | |
| - os: ubuntu-24.04-arm | |
| artifact: aarch64-linux | |
| - os: macos-15-intel | |
| artifact: x86_64-darwin | |
| - os: macos-14 | |
| artifact: arm64-darwin | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: oxidize-rb/actions/setup-ruby-and-rust@v1 | |
| with: | |
| ruby-version: "3.1" | |
| bundler-cache: true | |
| cargo-cache-clean: false | |
| - name: Check tag version | |
| shell: bash | |
| run: | | |
| expected="${GITHUB_REF_NAME#v}" | |
| actual="$(ruby -Ilib -r dotenvx/version -e 'print Dotenvx::VERSION')" | |
| test "$actual" = "$expected" | |
| - run: bundle exec rake package:native | |
| - name: Test packaged gem | |
| shell: bash | |
| env: | |
| SMOKE_VALUE: World | |
| run: | | |
| gem install --local --ignore-dependencies pkg/*.gem | |
| ruby -e 'require "dotenvx"; abort unless Dotenvx.parse("spec/fixtures/process_env.env", ignore: false) == {"HELLO" => "World"}' | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.4" | |
| - name: Test packaged gem on a newer Ruby | |
| shell: bash | |
| env: | |
| SMOKE_VALUE: World | |
| run: | | |
| gem install --local --ignore-dependencies pkg/*.gem | |
| ruby -e 'require "dotenvx"; abort unless Dotenvx.parse("spec/fixtures/process_env.env", ignore: false) == {"HELLO" => "World"}' | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: gem-${{ matrix.artifact }} | |
| path: pkg/*.gem | |
| source-gem: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.4" | |
| - name: Check tag version | |
| shell: bash | |
| run: | | |
| expected="${GITHUB_REF_NAME#v}" | |
| actual="$(ruby -Ilib -r dotenvx/version -e 'print Dotenvx::VERSION')" | |
| test "$actual" = "$expected" | |
| - name: Build source gem | |
| run: | | |
| mkdir -p pkg | |
| gem build dotenvx.gemspec | |
| mv dotenvx-*.gem pkg/ | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: gem-source | |
| path: pkg/*.gem | |
| rails-gem: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.4" | |
| - name: Check tag version | |
| shell: bash | |
| run: | | |
| expected="${GITHUB_REF_NAME#v}" | |
| actual="$(ruby -Ilib -r dotenvx/version -e 'print Dotenvx::VERSION')" | |
| test "$actual" = "$expected" | |
| - name: Build Rails gem | |
| run: | | |
| mkdir -p pkg | |
| gem build dotenvx-rails.gemspec | |
| mv dotenvx-rails-*.gem pkg/ | |
| gem specification pkg/dotenvx-rails-*.gem | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: gem-rails | |
| path: pkg/*.gem | |
| publish: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: [native-gems, source-gem, rails-gem] | |
| runs-on: ubuntu-latest | |
| environment: release | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v6 | |
| with: | |
| pattern: gem-* | |
| path: pkg | |
| merge-multiple: true | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: "3.4" | |
| - name: Configure RubyGems credentials | |
| uses: rubygems/configure-rubygems-credentials@dc5a8d8553e6ee01fc26761a49e99e733d17954a # v2.1.0 | |
| - name: Publish platform gems | |
| run: | | |
| for gem in pkg/*.gem; do | |
| gem push "$gem" | |
| done |