Merge pull request #933 from SwedbankPay/dependabot/github_actions/gi… #14625
This file contains 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 Gem | |
on: [push, pull_request] | |
jobs: | |
variables: | |
runs-on: ubuntu-latest | |
outputs: | |
branch: ${{ steps.variables.outputs.branch }} | |
version: ${{ steps.variables.outputs.version }} | |
repository_url: ${{ steps.variables.outputs.repository_url }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x.x' | |
- id: gitversion | |
uses: gittools/actions/gitversion/[email protected] | |
- name: Generate variables | |
id: variables | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: .github/scripts/variables.sh ${{ steps.gitversion.outputs.legacySemVerPadded }} | |
gem: | |
needs: variables | |
runs-on: ubuntu-latest | |
outputs: | |
name: ${{ steps.gem.outputs.name }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.7 | |
bundler-cache: true | |
- name: Build gem | |
id: gem | |
run: .github/scripts/build_gem.sh --version "${{ needs.variables.outputs.version }}" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.gem.outputs.name }} | |
path: ${{ steps.gem.outputs.name }} | |
- uses: actions/setup-java@v4 | |
with: | |
distribution: adopt | |
java-version: 14 | |
- uses: kamiazya/setup-graphviz@v1 | |
- name: Test gem | |
run: .github/scripts/test_gem.sh --workdir "${{ github.workspace }}/spec/fixture" --verbose | |
publish: | |
needs: gem | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.gem.outputs.name }} | |
- name: Publish to GPR | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: .github/scripts/publish_gem.sh --gem ${{ needs.gem.outputs.name }} --token $GITHUB_TOKEN --verbose | |
- name: Publish to RubyGems | |
if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits | |
env: | |
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | |
run: .github/scripts/publish_gem.sh --gem ${{ needs.gem.outputs.name }} --key $RUBYGEMS_API_KEY --verbose |