name: CI on: [push] env: GITHUB_PACKAGES_TOKEN: ${{ secrets.GP_REPO_PACKAGE_R }} jobs: lint: name: Lint runs-on: self-hosted-base steps: - uses: actions/checkout@v3 - name: Set up Ruby 2.7 uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 - name: Lint Ruby code with RuboCop run: | gem install bundler bundle config set --global rubygems.pkg.github.com ${GITHUB_PACKAGES_TOKEN} bundle install --jobs 4 --retry 3 bundle exec rubocop test: runs-on: self-hosted-base needs: lint strategy: matrix: ruby: [2.7, 3.0, 3.1] steps: - uses: actions/checkout@v3 - name: Set up Ruby ${{ matrix.ruby }} uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - name: Build and test with RSpec run: | gem install bundler bundle config set --global rubygems.pkg.github.com ${GITHUB_PACKAGES_TOKEN} bundle install --jobs 4 --retry 3 bundle exec rspec - name: Coveralls Parallel uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: run-${{ matrix.ruby }} parallel: true test-finish: needs: test name: Publish to Coveralls runs-on: self-hosted-base steps: - name: Coveralls Finished uses: coverallsapp/github-action@master with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true publish: needs: test name: Publish to GitHub Packages if: github.head_ref == 'main' || github.ref_name == 'main' runs-on: self-hosted-base steps: - uses: actions/checkout@v3 - name: Set up Ruby 2.7 uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 - name: Set Credentials run: | mkdir -p $HOME/.gem touch $HOME/.gem/credentials chmod 0600 $HOME/.gem/credentials printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Publish to GitHub Packages run: | gem build go_puff-tax_service.gemspec gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem echo "release_version=v"`find . -iname "*.gem" | sed -ne "s/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9]\).*/\1/p"` >> $GITHUB_ENV env: OWNER: ${{ github.repository_owner }} - name: Create a Release uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: ${{secrets.GITHUB_TOKEN}} automatic_release_tag: ${{ env.release_version }} prerelease: false publish-beta: needs: test name: Publish Beta to GitHub Packages if: github.ref != 'refs/heads/main' runs-on: self-hosted-base steps: - uses: actions/checkout@v3 - name: Set up Ruby 2.7 uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 - name: Set Credentials run: | mkdir -p $HOME/.gem touch $HOME/.gem/credentials chmod 0600 $HOME/.gem/credentials printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - name: Publish to GitHub Packages run: | gem build go_puff-tax_service.gemspec find . -iname "*-*.*.*.*.gem" | grep . if [ $? -eq 1 ] then echo "Version does not contain beta/alpha prefix. Please check version.rb file." exit 1 fi gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem echo "release_version=v"`find . -iname "*.gem" | sed -ne "s/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9]\).*/\1/p"` >> $GITHUB_ENV env: OWNER: ${{ github.repository_owner }}