Skip to content

🤝 Sync alphagov/main into this repository (#5) #8

🤝 Sync alphagov/main into this repository (#5)

🤝 Sync alphagov/main into this repository (#5) #8

Workflow file for this run

name: Publish
on:
push:
branches:
- main
workflow_dispatch:
concurrency: rubygems
jobs:
pre:
name: Pre-flight checks
runs-on: ubuntu-latest
outputs:
go: ${{ steps.gem_version.outputs.new_version }}
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3'
- name: Check if new version to release
id: gem_version
run: |
gem_version=$(ruby -r rubygems -e "puts Gem::Specification::load('govuk_tech_docs.gemspec').version")
echo "gem_version=$gem_version" >> "$GITHUB_OUTPUT"
if git fetch origin "refs/tags/v${gem_version}" >/dev/null 2>&1
then
echo "Tag 'v$gem_version' already exists"
echo "new_version=false" >> "$GITHUB_OUTPUT"
else
echo "new_version=true" >> "$GITHUB_OUTPUT"
fi
deploy:
name: Publish Ruby Gem
environment: github-package-registry
permissions:
contents: write # needed to be able to tag the release
packages: write # needed to be able to publish the gem
runs-on: ubuntu-latest
needs: pre
if: ${{ needs.pre.outputs.go == 'true' }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3'
bundler-cache: true
- name: Publish
uses: dawidd6/action-publish-gem@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}