-
Notifications
You must be signed in to change notification settings - Fork 4
168 lines (141 loc) · 4.13 KB
/
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
161
162
163
164
165
166
167
168
name: release
on:
workflow_dispatch:
inputs:
next_version:
description: |
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
required: true
default: 'patch'
push:
tags: [ v* ]
concurrency:
group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
cancel-in-progress: true
jobs:
bump:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@master
with:
ruby-version: '3.2'
- if: ${{ github.event_name == 'workflow_dispatch' }} # unfortunatelly cannot keep this condition on job level
run: |
git config --global user.name github-actions
git config --global user.email github-actions@github.com
gem install gem-release
gem bump --version ${{ github.event.inputs.next_version }} --tag --push
pack:
runs-on: ubuntu-latest
needs: bump
strategy:
fail-fast: false
matrix:
platform: [ linux-gnu, linux-musl, windows, darwin ]
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@master
with:
ruby-version: '3.2'
bundler-cache: true
- name: Build gem and save version
if: matrix.platform == 'linux-gnu'
run: |
gem build expressir.gemspec | grep -o 'Version: .*' | awk '{print $2}' > version
- if: matrix.platform == 'linux-gnu'
uses: actions/upload-artifact@v4
with:
name: pkg-ruby
path: expressir-*.gem
- if: matrix.platform == 'linux-gnu'
uses: actions/upload-artifact@v4
with:
name: version
path: version
# build gem WITH pre-built native extension
- run: bundle exec rake gem:${{ matrix.platform }}
- uses: actions/upload-artifact@v4
with:
name: pkg-${{ matrix.platform }}
path: pkg/*.gem
publish:
runs-on: ubuntu-latest
needs: pack
steps:
- uses: actions/download-artifact@v4
with:
name: pkg-ruby
path: pkg
- uses: actions/download-artifact@v4
with:
name: pkg-linux-gnu
path: pkg
- uses: actions/download-artifact@v4
with:
name: pkg-linux-musl
path: pkg
- uses: actions/download-artifact@v4
with:
name: pkg-windows
path: pkg
- uses: actions/download-artifact@v4
with:
name: pkg-darwin
path: pkg
- uses: ruby/setup-ruby@master
with:
ruby-version: '3.1'
- name: Publish to rubygems.org
env:
RUBYGEMS_API_KEY: ${{ secrets.LUTAML_CI_RUBYGEMS_API_KEY }}
run: |
ls -l pkg/
mkdir -p ~/.gem
cat > ~/.gem/credentials << EOF
---
:rubygems_api_key: ${RUBYGEMS_API_KEY}
EOF
chmod 0600 ~/.gem/credentials
gem signin
for gem in pkg/*.gem; do gem push $gem -V; done
sleep 15
verify:
name: Verify published gem on ${{ matrix.os }}
needs: publish
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- name: Install Ruby
uses: ruby/setup-ruby@master
with:
ruby-version: 3.2
bundler-cache: true
- name: Download version
uses: actions/download-artifact@v4
with:
name: version
- name: Install gem
run: gem install expressir -v $(cat version)
- name: Verify
run: expressir version
verify-alpine:
name: Verify published gem on alpine
needs: publish
runs-on: ubuntu-latest
container:
image: alpine:3.17
steps:
- name: Install packages
run: apk --no-cache add bash build-base git ruby-dev gcc g++ automake
- name: Download version
uses: actions/download-artifact@v4
with:
name: version
- name: Install gem
run: gem install expressir -v $(cat version)
- name: Verify
run: expressir version