Merge pull request #191 from Crown-Commercial-Service/dependabot/bund… #72
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: Publish the gem to RubyGems | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: publish | |
jobs: | |
test: | |
uses: ./.github/workflows/test.yml | |
check_for_release: | |
needs: [test] | |
runs-on: ubuntu-latest | |
outputs: | |
ruby: ${{ steps.package_version.outputs.ruby }} | |
ruby_semver: ${{ steps.package_version.outputs.ruby_semver }} | |
exists: ${{ steps.version_tag.outputs.exists }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Get package version | |
id: package_version | |
run: | | |
echo "ruby=$(./bin/version)" >> $GITHUB_OUTPUT | |
echo "ruby_semver=$(./bin/semver)" >> $GITHUB_OUTPUT | |
- name: Check if version tag already exists | |
id: version_tag | |
uses: mukunku/tag-exists-action@bdad1eaa119ce71b150b952c97351c75025c06a9 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag: v${{ steps.package_version.outputs.ruby }} | |
publish: | |
if: ${{ needs.check_for_release.outputs.exists == 'false' }} | |
runs-on: ubuntu-latest | |
needs: [check_for_release] | |
permissions: | |
id-token: write | |
contents: write | |
environment: ruby-gems | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Publish packaged to RubyGems | |
uses: rubygems/release-gem@v1 | |
release: | |
if: ${{ needs.check_for_release.outputs.exists == 'false' }} | |
runs-on: ubuntu-latest | |
needs: [publish, check_for_release] | |
permissions: | |
id-token: write | |
contents: write | |
environment: ruby-gems | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Changelog Entry | |
id: changelog_reader | |
uses: mindsers/changelog-reader-action@v2 | |
with: | |
validation_level: warn | |
version: ${{ needs.check_for_release.outputs.ruby_semver }} | |
- name: Create GitHub release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v${{ needs.check_for_release.outputs.ruby }} | |
name: CCS Frontend Helpers v${{ needs.check_for_release.outputs.ruby }} | |
prerelease: ${{ contains(needs.check_for_release.outputs.ruby, 'beta') }} | |
body: ${{ steps.changelog_reader.outputs.changes }} |