Initial commit: v0.1.0 #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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| release: | |
| types: [ published ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| strategy: | |
| matrix: | |
| ruby-version: ['3.2', '3.3'] | |
| 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: false | |
| - name: Generate prebuild artifacts | |
| run: | | |
| gem install bundler | |
| bundle install | |
| bundle exec rake prebuild | |
| - name: Install dependencies | |
| run: | | |
| bundle install --jobs 4 --retry 3 | |
| - name: RSpec tests | |
| run: bundle exec rake rspec | |
| - name: CLI sanity checks | |
| run: bundle exec rake cli_test | |
| gem-build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.event_name == 'release' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.2' | |
| bundler-cache: true | |
| - name: Build gem | |
| run: | | |
| bundle exec rake prebundle | |
| ls -l pkg/ | |
| # Uncomment to publish to RubyGems when ready | |
| # - name: Publish to RubyGems | |
| # if: env.RUBYGEMS_API_KEY != '' | |
| # env: | |
| # RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | |
| # run: | | |
| # mkdir -p ~/.gem | |
| # echo ":rubygems_api_key: ${RUBYGEMS_API_KEY}" > ~/.gem/credentials | |
| # chmod 0600 ~/.gem/credentials | |
| # gem push pkg/releasehx-*.gem | |
| docker-build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.event_name == 'release' || github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image (test only) | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| tags: docopslab/releasehx:test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Smoke test Docker image | |
| run: | | |
| docker run --rm -v $PWD:/workdir docopslab/releasehx:test rhx --version || true | |
| docker run --rm -v $PWD:/workdir docopslab/releasehx:test rhx --help || true |