-
Notifications
You must be signed in to change notification settings - Fork 61
102 lines (92 loc) · 2.97 KB
/
build-gems.yml
File metadata and controls
102 lines (92 loc) · 2.97 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
name: Build gems
on:
push:
branches: [main]
paths-ignore:
- "*.md"
- "docs/**"
pull_request:
workflow_call:
inputs:
publish:
type: boolean
default: false
ref:
type: string
required: true
jobs:
ci-data:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.fetch.outputs.result }}
steps:
- uses: oxidize-rb/actions/fetch-ci-data@v1
id: fetch
with:
supported-ruby-platforms: |
exclude: [arm-linux, x64-mingw32, aarch64-mingw-ucrt]
stable-ruby-versions: |
exclude: [head]
cross-gem:
name: Compile native gem for ${{ matrix.ruby-platform }}
runs-on: ubuntu-latest
needs: ci-data
strategy:
fail-fast: false
matrix:
ruby-platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref || github.ref }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
- name: Detect rb-sys version from Cargo.lock
id: rb-sys
run: |
version="$(awk '/name = "rb-sys"/{flag=1; next} flag && /version = / {gsub(/"/, "", $3); print $3; exit}' Cargo.lock)"
if [ -z "$version" ]; then
echo "Failed to detect rb-sys version from Cargo.lock" >&2
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Build native gem with rb-sys-dock
id: cross-gem
env:
PLATFORM: ${{ matrix.ruby-platform }}
RUBY_VERSIONS: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
RB_SYS_VERSION: ${{ steps.rb-sys.outputs.version }}
run: |
gem install rb_sys -v "$RB_SYS_VERSION"
rb-sys-dock --platform "$PLATFORM" --directory . --ruby-versions "$RUBY_VERSIONS" --build
gem_path="$(find ./pkg -name "*-${PLATFORM}.gem" | head -n1)"
if [ -z "$gem_path" ]; then
echo "Failed to find built gem for ${PLATFORM}" >&2
ls -la ./pkg || true
exit 1
fi
echo "gem-path=$gem_path" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v7
with:
name: cross-gem-${{ matrix.ruby-platform }}
path: ${{ steps.cross-gem.outputs.gem-path }}
if-no-files-found: error
- uses: rubygems/configure-rubygems-credentials@v1.0.0
if: ${{ inputs.publish }}
- run: gem push "${{ steps.cross-gem.outputs.gem-path }}"
if: ${{ inputs.publish }}
push-src-gem:
name: Push source gem
runs-on: ubuntu-latest
if: ${{ inputs.publish }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ inputs.ref || github.ref }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
- uses: rubygems/configure-rubygems-credentials@v1.0.0
- run: gem build
- run: gem push ruby_wasm-*.gem