Repository navigation
202 lines (182 loc) · 6.31 KB
/
Copy pathrelease.yml
File metadata and controls
202 lines (182 loc) · 6.31 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
dry_run:
description: "Build & verify all gems without pushing to RubyGems"
type: boolean
default: true
permissions:
contents: read
jobs:
verify-metadata:
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.ver.outputs.version }}
publish: ${{ steps.ver.outputs.publish }}
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
- name: Verify version and CHANGELOG consistency
id: ver
run: |
VERSION=$(ruby -Ilib -rexecutorch/version -e 'puts Executorch::VERSION')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
grep -Fq "## [$VERSION]" CHANGELOG.md || {
echo "CHANGELOG.md is missing heading: ## [$VERSION]"
exit 1
}
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
TAG_VER="${GITHUB_REF#refs/tags/v}"
if [[ "$TAG_VER" != "$VERSION" ]]; then
echo "Tag v$TAG_VER does not match Executorch::VERSION ($VERSION)"
exit 1
fi
echo "publish=true" >> "$GITHUB_OUTPUT"
elif [[ "${{ inputs.dry_run }}" == "false" ]]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
else
echo "publish=false" >> "$GITHUB_OUTPUT"
fi
build-platform-gems:
needs: verify-metadata
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
platform: x86_64-linux
- os: ubuntu-24.04-arm
platform: aarch64-linux
- os: macos-15
platform: arm64-darwin
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "test/fixtures/pyproject.toml"
- name: Export fixtures for pre-release verification
run: |
uv run --project test/fixtures python test/fixtures/export_fixtures.py --out test/fixtures/models
- name: Compile Ruby 3.2 extension
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.2"
bundler-cache: false
- run: |
rm -rf Gemfile.lock .bundle vendor/bundle
bundle install --jobs 4
EXECUTORCH_BUNDLE_VENDOR=1 bundle exec rake sdk:fetch compile
bundle exec rake test
mkdir -p staged/3.2
cp lib/executorch/executorch.* staged/3.2/
- name: Compile Ruby 3.3 extension
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: false
- run: |
rm -rf Gemfile.lock .bundle vendor/bundle
bundle install --jobs 4
EXECUTORCH_BUNDLE_VENDOR=1 bundle exec rake clean compile
bundle exec rake test
mkdir -p staged/3.3
cp lib/executorch/executorch.* staged/3.3/
- name: Compile Ruby 3.4 extension & assemble fat gem
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: false
- run: |
rm -rf Gemfile.lock .bundle vendor/bundle
bundle install --jobs 4
EXECUTORCH_BUNDLE_VENDOR=1 bundle exec rake clean compile
bundle exec rake test
mkdir -p lib/executorch/3.2 lib/executorch/3.3 lib/executorch/3.4
cp staged/3.2/executorch.* lib/executorch/3.2/
cp staged/3.3/executorch.* lib/executorch/3.3/
mv lib/executorch/executorch.* lib/executorch/3.4/
ruby -e '
require "fileutils"
require "rubygems/package"
spec = Gem::Specification.load("executorch.gemspec")
spec.platform = Gem::Platform.new("${{ matrix.platform }}")
spec.extensions = []
spec.files = (
spec.files.reject { |f| f.start_with?("ext/") } +
Dir["lib/executorch/3.*/*"] +
Dir["lib/executorch/vendor/*"]
).uniq.sort
FileUtils.mkdir_p("pkg")
out = Gem::Package.build(spec)
FileUtils.mv(out, File.join("pkg", File.basename(out)))
'
# Isolated smoke test without SDK cache
rm -rf ~/.cache/executorch-ruby
GEM_HOME=$(mktemp -d)
GEM_HOME="$GEM_HOME" gem install --local --no-document pkg/executorch-*-${{ matrix.platform }}.gem
GEM_HOME="$GEM_HOME" ruby -rexecutorch -e '
raise "missing XNNPACK" unless Executorch.backends.include?("XnnpackBackend")
puts "Verified fat gem: #{Executorch::VERSION} (#{Executorch.backends.inspect})"
'
- uses: actions/upload-artifact@v4
with:
name: gem-${{ matrix.platform }}
path: pkg/*.gem
build-source-gem:
needs: verify-metadata
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
- run: |
mkdir -p pkg
gem build executorch.gemspec -o "pkg/executorch-${{ needs.verify-metadata.outputs.version }}.gem"
- uses: actions/upload-artifact@v4
with:
name: gem-source
path: pkg/*.gem
publish:
needs: [verify-metadata, build-platform-gems, build-source-gem]
if: needs.verify-metadata.outputs.publish == 'true'
runs-on: ubuntu-24.04
environment: release
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Configure RubyGems Trusted Publishing (OIDC)
uses: rubygems/configure-rubygems-credentials@v2.1.0
- name: Push verified gems to RubyGems
run: |
for g in dist/*.gem; do
echo "Pushing $g"
gem push "$g"
done
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${GITHUB_REF_NAME}" dist/*.gem \
--title "v${{ needs.verify-metadata.outputs.version }}" \
--generate-notes