Repository navigation
164 lines (155 loc) · 4.85 KB
/
Copy pathruby.yml
File metadata and controls
164 lines (155 loc) · 4.85 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
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
name: Ruby Release
on:
push:
tags:
- "v*"
pull_request:
paths:
- "bindings/ruby/**"
- ".github/workflows/ruby.yml"
workflow_dispatch:
inputs:
publish:
description: Publish the current main version to RubyGems
type: boolean
required: true
default: false
permissions:
contents: read
jobs:
source:
name: Build source gem
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
- name: Verify release version
run: scripts/check-release-versions.sh
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true
working-directory: bindings/ruby
- name: Build source gem
working-directory: bindings/ruby
run: |
gem build ironpress.gemspec
mkdir -p pkg
mv ironpress-*.gem pkg/
- uses: actions/upload-artifact@v7
with:
name: gem-source
path: bindings/ruby/pkg/*.gem
native:
name: Build native gem - ${{ matrix.platform }}
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
platform:
- x86_64-linux
- aarch64-linux
- x86_64-darwin
- arm64-darwin
- x64-mingw-ucrt
steps:
- uses: actions/checkout@v7
- name: Verify release version
run: scripts/check-release-versions.sh
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
- name: Cross-compile native gem
id: cross-gem
uses: oxidize-rb/actions/cross-gem@v1
with:
platform: ${{ matrix.platform }}
ruby-versions: "3.1,3.2,3.3,3.4"
working-directory: bindings/ruby
cache-version: v1
- uses: actions/upload-artifact@v7
with:
name: gem-${{ matrix.platform }}
path: ${{ steps.cross-gem.outputs.gem-path }}
test-linux:
name: Test native gem - Ruby ${{ matrix.ruby-version }}
needs: [native]
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
ruby-version: ["3.1", "3.4"]
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- uses: actions/download-artifact@v8
with:
name: gem-x86_64-linux
path: pkg
- name: Install the built gem
run: gem install --local pkg/*.gem
- name: Test the installed gem
run: ruby bindings/ruby/test/bindings_test.rb
publish:
name: Publish to RubyGems
needs: [source, native, test-linux]
runs-on: ubuntu-latest
timeout-minutes: 20
if: >-
startsWith(github.ref, 'refs/tags/v') ||
(github.event_name == 'workflow_dispatch' &&
github.ref == 'refs/heads/main' && inputs.publish)
steps:
- uses: actions/download-artifact@v8
with:
pattern: gem-*
merge-multiple: true
path: pkg
- name: Wait for the matching Rust crate
run: |
version="$(ruby -rrubygems/package -e '
path = Dir["pkg/*.gem"].find do |candidate|
Gem::Package.new(candidate).spec.platform.to_s == "ruby"
end
abort "source gem not found" unless path
puts Gem::Package.new(path).spec.version
')"
for attempt in {1..40}; do
if curl --fail --silent --connect-timeout 5 --max-time 15 \
--user-agent "ironpress-release/${version} (https://github.com/gastongouron/ironpress)" \
"https://crates.io/api/v1/crates/ironpress/${version}" >/dev/null; then
break
fi
if [[ "$attempt" == 40 ]]; then
echo "ironpress ${version} is not available on crates.io" >&2
exit 1
fi
sleep 15
done
- name: Publish to RubyGems
env:
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_TOKEN }}
run: |
mkdir -p ~/.gem
echo "---" > ~/.gem/credentials
echo ":rubygems_api_key: ${GEM_HOST_API_KEY}" >> ~/.gem/credentials
chmod 0600 ~/.gem/credentials
for gem in pkg/*.gem; do
mapfile -t metadata < <(
ruby -rrubygems/package -e \
'spec = Gem::Package.new(ARGV.fetch(0)).spec; puts spec.name, spec.version, spec.platform' \
"$gem"
)
name="${metadata[0]}"
version="${metadata[1]}"
platform="${metadata[2]}"
url="https://rubygems.org/api/v2/rubygems/${name}/versions/${version}.json"
if curl --fail --silent "${url}?platform=${platform}" >/dev/null; then
echo "${name} ${version} (${platform}) is already published"
else
gem push "$gem"
fi
done