Bump actions/checkout from 3 to 4 #1006
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, pull_request_target] | |
jobs: | |
version: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.variables.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup GitVersion | |
uses: gittools/actions/gitversion/setup@v0.9.15 | |
with: | |
versionSpec: '5.x.x' | |
- name: Execute GitVersion | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0.9.15 | |
- name: Create variables | |
id: variables | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: ./.github/scripts/variables.sh ${{ steps.gitversion.outputs.fullSemVer }} | |
plantuml: | |
needs: version | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: adopt | |
java-version: 14 | |
- name: Cache Maven dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: Version stamp | |
run: mvn versions:set -DnewVersion=${{ needs.version.outputs.version }} | |
- name: Maven install | |
run: mvn install | |
- name: Upload plantuml.jar artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: plantuml.jar | |
path: ~/.m2/repository/**/plantuml*.jar | |
gem: | |
needs: [version, plantuml] | |
runs-on: ubuntu-latest | |
outputs: | |
name: ${{ steps.gem.outputs.name }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: plantuml.jar | |
path: bin/ | |
- name: Version stamp | |
run: sed -i -e 's/0.0.1.dev/${{ needs.version.outputs.version }}/g' ${{ github.workspace }}/lib/kramdown-plantuml/version.rb | |
- name: Setup Ruby 2.7 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.7 | |
bundler-cache: true | |
- name: Setup Graphviz | |
uses: kamiazya/setup-graphviz@v1 | |
- name: rubocop | |
run: bundle exec rubocop --fail-level warning --display-only-fail-level-offenses | |
- name: RSPec (debug) | |
env: | |
DEBUG: 1 | |
run: bundle exec rspec --format documentation --tag debug | |
- name: Upload code coverage (debug) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: rspec-debug-coverage | |
path: ./coverage | |
- name: Codecov upload (debug) | |
run: bundle exec rake codecov:upload || echo 'Codecov upload failed' | |
- name: Test with Rake | |
run: bundle exec rake | |
- name: Upload code coverage | |
uses: actions/upload-artifact@v3 | |
with: | |
name: rspec-coverage | |
path: ./coverage | |
- name: Codecov upload | |
run: bundle exec rake codecov:upload || echo 'Codecov upload failed' | |
- name: RSPec (Jekyll) | |
run: | | |
echo "gem 'jekyll', require: false, group: :test" >> Gemfile | |
bundle install | |
bundle exec rspec --format documentation --tag jekyll | |
git checkout HEAD -- Gemfile | |
- name: Upload code coverage (Jekyll) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: rspec-jekyll-coverage | |
path: ./coverage | |
- name: Codecov upload (Jekyll) | |
run: bundle exec rake codecov:upload || echo 'Codecov upload failed' | |
- name: Build gem | |
id: gem | |
run: .github/scripts/build-gem.sh --ref ${{ github.ref }} --verbose | |
- name: Upload gem | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.gem.outputs.name }} | |
path: ${{ steps.gem.outputs.name }} | |
- name: Inspect gem | |
run: .github/scripts/inspect-gem.sh --gem "${{ github.workspace }}/${{ steps.gem.outputs.name }}" --verbose | |
- name: Test gem | |
run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/examples" --gemdir "${{ github.workspace }}" --verbose | |
- name: Upload code coverage (gem) | |
uses: actions/upload-artifact@v3 | |
with: | |
name: gem-coverage | |
path: ./coverage | |
- name: Codecov upload (gem) | |
run: bundle exec rake codecov:upload || echo 'Codecov upload failed' | |
publish-dev: | |
needs: [version, gem] | |
runs-on: ubuntu-latest | |
if: | | |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') || | |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') | |
steps: | |
- uses: actions/checkout@v4 | |
if: ${{ github.event_name != 'pull_request_target' }} | |
- uses: actions/checkout@v4 | |
if: ${{ github.event_name == 'pull_request_target' }} | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- uses: actions/download-artifact@v3 | |
with: | |
name: ${{ needs.gem.outputs.name }} | |
- name: Set up Ruby 2.7 | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.7 | |
bundler-cache: true | |
- name: Setup Graphviz | |
uses: kamiazya/setup-graphviz@v1 | |
- name: Publish to GPR | |
run: .github/scripts/publish-gem.sh --gem ${{ needs.gem.outputs.name }} --token "${{ secrets.GPR_TOKEN }}" --owner SwedbankPay --verbose | |
- name: Test gem (no theme) | |
run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/examples" --version ${{ needs.version.outputs.version }} --token "${{ secrets.GPR_TOKEN }}" --verbose | |
- name: Test gem (built-in theme) | |
run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/examples" --version ${{ needs.version.outputs.version }} --token "${{ secrets.GPR_TOKEN }}" --verbose --theme-name spacelab | |
- name: Test gem (custom theme) | |
run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/examples" --version ${{ needs.version.outputs.version }} --token "${{ secrets.GPR_TOKEN }}" --verbose --theme-name c2a3b0 --theme-directory "${{ github.workspace }}/spec/examples" | |
- name: Upload Jekyll site | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: site | |
path: ${{ github.workspace }}/spec/examples/_site | |
publish-prod: | |
needs: [version, gem] | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: ${{ needs.gem.outputs.name }} | |
- name: Publish to RubyGems | |
run: .github/scripts/publish-gem.sh --gem ${{ needs.gem.outputs.name }} --token ${{ secrets.RUBYGEMS_API_KEY }} --verbose |