-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (81 loc) · 2.21 KB
/
ci.yml
File metadata and controls
96 lines (81 loc) · 2.21 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: CI
on:
release:
types: [published]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Run tests
run: bundle exec rspec
env:
TAPSILAT_API_TOKEN: ${{ secrets.TAPSILAT_API_TOKEN }}
- name: Run RuboCop
run: bundle exec rubocop
- name: Generate coverage report
run: bundle exec rake coverage
env:
COVERAGE: true
TAPSILAT_API_TOKEN: ${{ secrets.TAPSILAT_API_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.ruby-version == '3.4'
with:
file: ./coverage/coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true
- name: Run bundle audit
run: |
gem install bundler-audit
bundle audit check --update
publish:
# Publish gem when a tag like v1.2.3 is pushed
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true
- name: Build gem
run: |
gem build *.gemspec
mkdir -p pkg
mv *.gem pkg/ || true
- name: Publish to RubyGems
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
run: |
if [ -z "${RUBYGEMS_API_KEY}" ]; then
echo "RUBYGEMS_API_KEY is not set. Skipping publish.";
exit 1;
fi
mkdir -p ~/.gem
printf "---\n:rubygems_api_key: %s\n" "$RUBYGEMS_API_KEY" > ~/.gem/credentials
chmod 0600 ~/.gem/credentials
ls -la pkg || true
gem push pkg/*.gem