Skip to content

Merge pull request #374 from alphagov/stable-sort-left-nav #58

Merge pull request #374 from alphagov/stable-sort-left-nav

Merge pull request #374 from alphagov/stable-sort-left-nav #58

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@v4
with:
show-progress: false
- 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: rubygems
permissions:
contents: write # needed to be able to tag the release
runs-on: ubuntu-latest
needs: pre
if: needs.pre.outputs.go == 'true'
steps:
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3'
bundler-cache: true
- name: Publish
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
run: |
mkdir -p ~/.gem
cat << EOF > ~/.gem/credentials
---
:rubygems_api_key: ${RUBYGEMS_API_KEY}
EOF
chmod 0600 ~/.gem/credentials
# tag will be associated with github-actions bot user, see
# https://github.community/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
bundle exec rake release