Merge pull request #12 from tinify/fix/get_body #44
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: Ruby CI/CD | |
| on: [push, pull_request] | |
| permissions: {} | |
| jobs: | |
| Unit_tests: | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 10 | |
| # continue-on-error: ${{ matrix.experimental }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ruby-version: ['3.1', '3.2', '3.3', '3.4', 'jruby'] | |
| os: [ubuntu-latest, macOS-latest, windows-latest] | |
| # experimental: [false] | |
| include: | |
| # TruffleRuby on Windows may fail | |
| # commented out, because it marks the build as failed with a red cross (X) | |
| # - ruby-version: truffleruby | |
| # os: windows-latest | |
| # experimental: true | |
| - ruby-version: truffleruby | |
| os: macOS-latest | |
| experimental: false | |
| - ruby-version: truffleruby | |
| os: ubuntu-latest | |
| experimental: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up ruby ${{ matrix.ruby-version }} | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: bundle install | |
| - name: Run specs | |
| run: bundle exec rake | |
| Integration_tests: | |
| if: github.event_name == 'push' | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 10 | |
| needs: Unit_tests | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| ruby-version: [ | |
| "3.1", "3.4" | |
| ] | |
| os: [ | |
| ubuntu-latest, | |
| macOS-latest, | |
| # Disable windows due to an issue with binary encoding in the tests | |
| # windows-latest | |
| ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up ruby ${{ matrix.ruby-version }} | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: | | |
| bundle install | |
| - name: Run tests | |
| env: | |
| TINIFY_KEY: ${{ secrets.TINIFY_KEY }} | |
| run: | | |
| bundle exec rake integration | |
| Publish: | |
| if: | | |
| github.repository == 'tinify/tinify-ruby' && | |
| startsWith(github.ref, 'refs/tags') && | |
| github.event_name == 'push' | |
| timeout-minutes: 10 | |
| needs: [Unit_tests, Integration_tests] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Ruby 3.4 | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: 3.4 | |
| - name: Check if properly tagged | |
| run: | | |
| PACKAGE_VERSION="$(ruby -e 'puts Gem::Specification::load("tinify.gemspec").version')"; | |
| CURRENT_TAG="${GITHUB_REF#refs/*/}"; | |
| if [[ "${PACKAGE_VERSION}" != "${CURRENT_TAG}" ]]; then | |
| >&2 echo "Tag mismatch" | |
| >&2 echo "Version in lib/tinify/version.rb (${PACKAGE_VERSION}) does not match the current tag=${CURRENT_TAG}" | |
| >&2 echo "Skipping deploy" | |
| exit 1; | |
| fi | |
| - run: bundle install | |
| - name: Publish to RubyGems | |
| run: | | |
| mkdir -p $HOME/.gem | |
| touch $HOME/.gem/credentials | |
| chmod 0600 $HOME/.gem/credentials | |
| printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | |
| gem build *.gemspec | |
| gem push *.gem | |
| env: | |
| GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}" |