forked from alphagov/tech-docs-gem
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (53 loc) · 1.57 KB
/
publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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 }}