-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (90 loc) · 3.34 KB
/
build-gems.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
---
# 👋 Look here for another good example: https://github.com/bytecodealliance/wasmtime-rb/tree/main/.github/workflows
name: Build, compile, and publish
on:
workflow_dispatch:
push:
tags:
- v*
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
ci-data:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.fetch.outputs.result }}
steps:
# This compiles for all supported Ruby cross-compilation platforms.
- id: fetch
uses: oxidize-rb/actions/fetch-ci-data@v1
with:
supported-ruby-platforms: |
exclude: [x64-mingw-ucrt, x64-mingw32]
stable-ruby-versions: |
exclude: [head]
cross_gems:
name: Cross compile gems
needs: ci-data
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
steps:
- uses: actions/checkout@v4
- name: Set variables
id: vars
run: |
if [[ "${{ inputs.rb-sys-branch }}" == "" ]]; then
echo "rb_sys_branch=main" >> $GITHUB_OUTPUT
else
echo "rb_sys_branch=${{ inputs.rb-sys-branch }}" >> $GITHUB_OUTPUT
fi
- name: Patch rb-sys version
id: patch
if: ${{ inputs.rb-sys-branch }}
run: |
mkdir -p .cargo
echo "[patch.crates-io]" >> .cargo/config.toml
echo "rb-sys = { git = \"https://github.com/oxidize-rb/rb-sys\", branch = \"${{ inputs.rb-sys-branch }}\" }" >> .cargo/config.toml
echo "rb-sys-env = { git = \"https://github.com/oxidize-rb/rb-sys\", branch = \"${{ inputs.rb-sys-branch }}\" }" >> .cargo/config.toml
sed -i "s|gem 'rb_sys', '.*'|gem 'rb_sys', github: 'oxidize-rb/rb-sys', branch: '${{ inputs.rb-sys-branch }}'|g" Gemfile
cargo update -p rb-sys
- uses: "ruby/setup-ruby@v1"
with:
ruby-version: "3.2"
bundler-cache: true
- uses: oxidize-rb/actions/cross-gem@v1
with:
platform: ${{ matrix.ruby-platform }}
tag: ${{ steps.vars.outputs.rb_sys_branch }}
ruby-versions: "3.3, 3.2, 3.1, 3.0"
- uses: actions/upload-artifact@v3
with:
name: cross-gem-${{ matrix.ruby-platform }}
path: pkg/*-${{ matrix.ruby-platform }}.gem
if-no-files-found: error
retention-days: 1
- name: "Set rb-sys version"
id: capture
run: |
echo "rb-sys-version=$(bundle exec rb-sys-dock --version)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v3
with:
name: rb-sys-bindings-${{ steps.capture.outputs.rb-sys-version }}
path: |
tmp/rb-sys-dock/${{ matrix.ruby-platform }}/**/cfg-capture*
tmp/rb-sys-dock/${{ matrix.ruby-platform }}/**/bindings*
tmp/${{ matrix.ruby-platform }}/
if-no-files-found: error
- name: "Publish to RubyGems"
id: publish
env:
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push pkg/*-${{ matrix.ruby-platform }}.gem