metanorma/mn2pdf-ruby

View on GitHub
.github/workflows/release.yml

Summary

Maintainability
Test Coverage
name: release

on:
  push:
    tags:
      - '*'
  workflow_dispatch:
    inputs:
      next_version:
        description: |
          Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
        required: true
        default: 'skip'

jobs:
  prepare:
    uses: metanorma/ci/.github/workflows/prepare-rake.yml@main

  release:
    runs-on: ubuntu-latest
    needs: prepare
    steps:
      - uses: actions/checkout@v3
        with:
          token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}

      - run: |
          git config user.name "metanorma-ci"
          git config user.email "metanorma-ci@users.noreply.github.com"

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ needs.prepare.outputs.default-ruby-version }}
          bundler-cache: true

      - if: github.event_name == 'workflow_dispatch' && inputs.next_version != 'skip'
        run: rm -f bin/mn2pdf.jar

      - run: bundle exec rake

      - run: gem install gem-release

      - if: github.event_name == 'workflow_dispatch' && inputs.next_version != 'skip'
        run: |
          gem bump --version ${{ inputs.next_version }} --no-commit
          git add -u lib/mn2pdf/version.rb
          git commit -m "Bump version to ${{ inputs.next_version }}"
          git tag v${{ inputs.next_version }}
          git push origin HEAD:${GITHUB_REF} --tags

      - uses: actions-mn/gem-release@main
        with:
          api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
          release-command: gem release

      - if: failure()
        uses: JasonEtco/create-an-issue@v2
        env:
          GITHUB_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
        with:
          assignees: CAMOBAP
          update_existing: true
          search_existing: all
          filename: .github/RELEASE_ISSUE_TEMPLATE.md