-
Notifications
You must be signed in to change notification settings - Fork 1
185 lines (163 loc) · 5.92 KB
/
Copy pathrelease.yml
File metadata and controls
185 lines (163 loc) · 5.92 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
build-native:
name: Build (${{ matrix.ruby-platform }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
ruby-platform: x86_64-linux
rust-target: x86_64-unknown-linux-gnu
- os: ubuntu-24.04-arm
ruby-platform: aarch64-linux
rust-target: aarch64-unknown-linux-gnu
- os: macos-15
ruby-platform: arm64-darwin
rust-target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust-target }}
- name: Install cross
if: matrix.use-cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Build CLI binary
run: cargo build --release -p methodray-core --features cli --bin methodray
- name: Build FFI extension
env:
# macOS: defer symbol resolution to runtime when loaded by Ruby
RUSTFLAGS: ${{ matrix.ruby-platform == 'arm64-darwin' && '-C link-arg=-undefined -C link-arg=dynamic_lookup' || '' }}
run: cargo build --release -p methodray --lib
- name: Copy binaries to lib directory
run: |
mkdir -p lib/methodray
# Debug: List build outputs
echo "=== Checking target/release/ ==="
ls -la target/release/ || echo "target/release/ does not exist"
# Copy CLI binary (from methodray-core package)
if [[ "${{ matrix.rust-target }}" == *"windows"* ]]; then
cp target/release/methodray.exe lib/methodray/methodray-cli.exe
else
cp target/release/methodray lib/methodray/methodray-cli
fi
chmod 755 lib/methodray/methodray-cli* || true
# Copy FFI extension (from methodray package in ext/)
case "${{ matrix.ruby-platform }}" in
*-darwin)
cp target/release/libmethodray.dylib lib/methodray/methodray.bundle
;;
*-linux)
cp target/release/libmethodray.so lib/methodray/methodray.so
;;
esac
ls -la lib/methodray/
- name: Generate RBS cache
run: |
echo "Generating RBS cache..."
ruby -I lib -rmethodray -e '1'
# Copy cache to lib directory for bundling
# macOS uses ~/Library/Caches, Linux uses ~/.cache
if [[ "${{ runner.os }}" == "macOS" ]]; then
CACHE_DIR="$HOME/Library/Caches/methodray"
else
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/methodray"
fi
echo "Looking for cache at: $CACHE_DIR/rbs_cache.bin"
if [ -f "$CACHE_DIR/rbs_cache.bin" ]; then
cp "$CACHE_DIR/rbs_cache.bin" lib/methodray/
echo "RBS cache copied to lib/methodray/"
ls -la lib/methodray/
else
echo "Error: RBS cache not found at $CACHE_DIR/rbs_cache.bin"
ls -la "$CACHE_DIR" || echo "Cache directory does not exist"
exit 1
fi
- name: Build platform gem
run: |
# Create platform-specific gemspec
cat > methodray-${{ matrix.ruby-platform }}.gemspec << 'EOF'
require_relative 'lib/methodray/version'
Gem::Specification.new do |spec|
spec.name = 'method-ray'
spec.version = MethodRay::VERSION
spec.platform = '${{ matrix.ruby-platform }}'
spec.authors = ['dak2']
spec.email = ['dak2.dev@gmail.com']
spec.summary = 'Method-Ray is a fast static analysis tool for Ruby methods.'
spec.description = 'A static analysis tool that checks the callability of methods in Ruby code.'
spec.homepage = 'https://github.com/dak2/method-ray'
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.4.0'
spec.files = Dir['lib/**/*', 'exe/*', 'README.md', 'LICENSE', 'CHANGELOG.md'] + ['lib/methodray/rbs_cache.bin']
spec.bindir = 'exe'
spec.executables = ['methodray']
spec.require_paths = ['lib']
spec.add_dependency 'rbs', '~> 3.0'
end
EOF
gem build methodray-${{ matrix.ruby-platform }}.gemspec
mkdir -p pkg
mv *.gem pkg/
- name: Upload gem artifact
uses: actions/upload-artifact@v6
with:
name: gem-${{ matrix.ruby-platform }}
path: pkg/*.gem
build-source:
name: Build source gem
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true
- name: Build source gem
run: |
gem build methodray.gemspec
mkdir -p pkg
mv *.gem pkg/
- name: Upload gem artifact
uses: actions/upload-artifact@v6
with:
name: gem-source
path: pkg/*.gem
release:
name: Release
needs: [build-native, build-source]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v5
with:
path: artifacts
- name: Collect all gems
run: |
mkdir -p release
find artifacts -name "*.gem" -exec cp {} release/ \;
ls -la release/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: release/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}