-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (128 loc) · 3.99 KB
/
test-and-release.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: test-and-release
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
concurrency:
group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
cancel-in-progress: true
env:
BUNDLER_VER: 2.4.22
# Forcing bundler version to ensure that it is consistent everywhere and
# does not cause bundler gem reinstalls
jobs:
prepare:
uses: metanorma/ci/.github/workflows/prepare-rake.yml@main
test:
name: Test on Ruby ${{ matrix.ruby.version }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: prepare
if: needs.prepare.outputs.push-for-tag != 'true'
continue-on-error: ${{ matrix.ruby.experimental }}
strategy:
fail-fast: false
max-parallel: 5
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@master
with:
ruby-version: ${{ matrix.ruby }}
rubygems: ${{ matrix.rubygems }}
bundler: ${{ env.BUNDLER_VER }}
bundler-cache: true
- run: bundle exec rake compile
- run: bundle exec rake
package-rake-compiler-dock:
name: Package native extensions (linux-gnu, windows, macos)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@master
with:
ruby-version: 3.1
bundler: ${{ env.BUNDLER_VER }}
bundler-cache: false
# bundler-cache:true breaks rake-compiler-dock logic
- run: bundle install --jobs 4 --retry 3
- run: bundle exec rake gem:parallel
- run: bundle exec rake build
- uses: actions/upload-artifact@v3
with:
name: pkg
path: pkg/*.gem
package-linux-musl-aarch64:
name: Package linux-musl-aarch64 extension
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# https://github.com/marketplace/actions/run-on-architecture
- uses: uraimo/run-on-arch-action@v2
name: Run commands
id: runcmd
with:
arch: aarch64
distro: alpine_latest
# Not required, but speeds up builds
githubToken: ${{ github.token }}
dockerRunArgs: --volume "${PWD}:/_a"
install: apk --no-cache --upgrade add git ruby-dev build-base autoconf
run: |
cd /_a
gem install bundler:${{ env.BUNDLER_VER }}
bundle install
bundle exec rake native gem
- uses: actions/upload-artifact@v3
with:
name: pkg
path: pkg/*.gem
package-linux-musl-x86_64:
name: Package linux-musl-x86_64 extension
runs-on: ubuntu-latest
container:
image: alpine:latest
steps:
- name: Install packages
run: apk --no-cache --upgrade add git ruby-dev build-base autoconf
- name: Configure git
run: git config --global --add safe.directory $(pwd)
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: |
gem install bundler:${{ env.BUNDLER_VER }}
bundle install
- name: Build native extension
run: bundle exec rake native gem
- uses: actions/upload-artifact@v3
with:
name: pkg
path: pkg/*.gem
release:
name: Release gem
runs-on: ubuntu-latest
if: contains(github.ref, 'refs/tags/v')
needs: [test, package-rake-compiler-dock, package-linux-musl-x86_64, package-linux-musl-aarch64]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: pkg
path: pkg
- name: Publish to rubygems.org
env:
RUBYGEMS_API_KEY: ${{secrets.FONTIST_CI_RUBYGEMS_API_KEY}}
run: |
mkdir -p ~/.gem
touch ~/.gem/credentials
cat > ~/.gem/credentials << EOF
---
:rubygems_api_key: ${RUBYGEMS_API_KEY}
EOF
chmod 0600 ~/.gem/credentials
gem signin
mkdir tmp
for gem in pkg/*.gem; do gem push -V $gem; done
# for gem in pkg/*.gem; do echo "Will call 'gem push -V $gem'"; done