-
Notifications
You must be signed in to change notification settings - Fork 10
68 lines (63 loc) · 2.22 KB
/
ci.yml
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
66
67
68
name: Continuous integration
on: [push, pull_request]
jobs:
# This matrix job runs the test suite against multiple Ruby and Rails versions
test_matrix:
strategy:
fail-fast: false
matrix:
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
ruby: [2.7, '3.0', 3.1]
# Test against multiple Rails versions
gemfile: [rails_6, rails_7]
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- uses: actions/[email protected]
with:
node-version: lts/* # use the latest LTS release
cache: yarn
- run: yarn install
- run: bundle exec rake
# This job is needed to work around the fact that matrix jobs spawn multiple status checks – i.e. one job per variant.
# The branch protection rules depend on this as a composite job to ensure that all preceding test_matrix checks passed.
# Solution taken from: https://github.521000.bestmunity/t/status-check-for-a-matrix-jobs/127354/3
test:
needs: test_matrix
runs-on: ubuntu-latest
steps:
- run: echo "All matrix tests have passed 🚀"
release:
needs: test
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
rubygems: latest
- uses: actions/[email protected]
with:
node-version: lts/* # use the latest LTS release
- run: yarn install
- env:
GEM_HOST_API_KEY: ${{ secrets.ALPHAGOV_RUBYGEMS_API_KEY }}
run: |
VERSION=$(ruby -e "puts eval(File.read('govuk_admin_template.gemspec')).version")
GEM_VERSION=$(gem list --exact --remote govuk_admin_template)
if [ "${GEM_VERSION}" != "govuk_admin_template (${VERSION})" ]; then
gem build govuk_admin_template.gemspec
gem push "govuk_admin_template-${VERSION}.gem"
fi
if ! git ls-remote --tags --exit-code origin v${VERSION}; then
git tag v${VERSION}
git push --tags
fi