Skip to content

Commit 08456c9

Browse files
committed
make ruby, make publish
1 parent b7f2b3f commit 08456c9

File tree

9 files changed

+126
-5
lines changed

9 files changed

+126
-5
lines changed

.github/workflows/release.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,53 @@ jobs:
264264
run: npm publish --access public
265265
env:
266266
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
267+
upload-gem:
268+
needs: [
269+
build-macos-extension,
270+
build-macos-arm-extension,
271+
build-ubuntu-extension,
272+
build-windows-extension,
273+
]
274+
permissions:
275+
contents: write
276+
runs-on: ubuntu-latest
277+
steps:
278+
- uses: actions/checkout@v2
279+
- uses: actions/download-artifact@v2
280+
- uses: ruby/setup-ruby@v1
281+
with:
282+
ruby-version: 3.2
283+
- run: |
284+
rm bindings/ruby/lib/*.{dylib,so,dll} || true
285+
cp sqlite-regex-macos/*.dylib bindings/ruby/lib
286+
gem -C bindings/ruby build -o x86_64-darwin.gem sqlite_regex.gemspec
287+
env:
288+
PLATFORM: x86_64-darwin
289+
- run: |
290+
rm bindings/ruby/lib/*.{dylib,so,dll} || true
291+
cp sqlite-regex-macos-arm/*.dylib bindings/ruby/lib
292+
gem -C bindings/ruby build -o arm64-darwin.gem sqlite_regex.gemspec
293+
env:
294+
PLATFORM: arm64-darwin
295+
- run: |
296+
rm bindings/ruby/lib/*.{dylib,so,dll} || true
297+
cp sqlite-regex-ubuntu/*.so bindings/ruby/lib
298+
gem -C bindings/ruby build -o x86_64-linux.gem sqlite_regex.gemspec
299+
env:
300+
PLATFORM: x86_64-linux
301+
- run: |
302+
rm bindings/ruby/lib/*.{dylib,so,dll} || true
303+
cp sqlite-regex-windows/*.dll bindings/ruby/lib
304+
gem -C bindings/ruby build -o ${{ env.PLATFORM }}.gem sqlite_regex.gemspec
305+
env:
306+
PLATFORM: x64-mingw32
307+
- run: |
308+
gem push bindings/ruby/x86_64-linux.gem
309+
gem push bindings/ruby/x86_64-darwin.gem
310+
gem push bindings/ruby/arm64-darwin.gem
311+
gem push bindings/ruby/x64-mingw32.gem
312+
env:
313+
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
267314
upload-pypi:
268315
needs:
269316
[

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ifdef target
3838
CARGO_TARGET=--target=$(target)
3939
BUILT_LOCATION=target/$(target)/debug/$(LIBRARY_PREFIX)sqlite_regex.$(LOADABLE_EXTENSION)
4040
BUILT_LOCATION_RELEASE=target/$(target)/release/$(LIBRARY_PREFIX)sqlite_regex.$(LOADABLE_EXTENSION)
41-
else
41+
else
4242
CARGO_TARGET=
4343
BUILT_LOCATION=target/debug/$(LIBRARY_PREFIX)sqlite_regex.$(LOADABLE_EXTENSION)
4444
BUILT_LOCATION_RELEASE=target/release/$(LIBRARY_PREFIX)sqlite_regex.$(LOADABLE_EXTENSION)
@@ -75,13 +75,13 @@ $(TARGET_LOADABLE_RELEASE): $(prefix) $(shell find . -type f -name '*.rs')
7575
cp $(BUILT_LOCATION_RELEASE) $@
7676

7777
python: $(TARGET_WHEELS) $(TARGET_LOADABLE) python/sqlite_regex/setup.py python/sqlite_regex/sqlite_regex/__init__.py .github/workflows/rename-wheels.py
78-
cp $(TARGET_LOADABLE) $(INTERMEDIATE_PYPACKAGE_EXTENSION)
78+
cp $(TARGET_LOADABLE) $(INTERMEDIATE_PYPACKAGE_EXTENSION)
7979
rm $(TARGET_WHEELS)/sqlite_regex* || true
8080
pip3 wheel python/sqlite_regex/ -w $(TARGET_WHEELS)
8181
python3 .github/workflows/rename-wheels.py $(TARGET_WHEELS) $(RENAME_WHEELS_ARGS)
8282

8383
python-release: $(TARGET_LOADABLE_RELEASE) $(TARGET_WHEELS_RELEASE) python/sqlite_regex/setup.py python/sqlite_regex/sqlite_regex/__init__.py .github/workflows/rename-wheels.py
84-
cp $(TARGET_LOADABLE_RELEASE) $(INTERMEDIATE_PYPACKAGE_EXTENSION)
84+
cp $(TARGET_LOADABLE_RELEASE) $(INTERMEDIATE_PYPACKAGE_EXTENSION)
8585
rm $(TARGET_WHEELS_RELEASE)/sqlite_regex* || true
8686
pip3 wheel python/sqlite_regex/ -w $(TARGET_WHEELS_RELEASE)
8787
python3 .github/workflows/rename-wheels.py $(TARGET_WHEELS_RELEASE) $(RENAME_WHEELS_ARGS)
@@ -109,12 +109,18 @@ python/sqlite_regex/sqlite_regex/version.py: VERSION
109109
python/datasette_sqlite_regex/datasette_sqlite_regex/version.py: VERSION
110110
printf '__version__ = "%s"\n__version_info__ = tuple(__version__.split("."))\n' `cat VERSION` > $@
111111

112+
bindings/ruby/lib/version.rb: bindings/ruby/lib/version.rb.tmpl VERSION
113+
VERSION=$(VERSION) envsubst < $< > $@
114+
115+
ruby: bindings/ruby/lib/version.rb
116+
112117
version:
113118
make Cargo.toml
114119
make python/sqlite_regex/sqlite_regex/version.py
115120
make python/datasette_sqlite_regex/datasette_sqlite_regex/version.py
116121
make npm
117122
make deno
123+
make ruby
118124

119125

120126
format:
@@ -156,12 +162,15 @@ test:
156162
make test-npm
157163
make test-deno
158164

165+
publish-release:
166+
./scripts/publish_release.sh
167+
159168
.PHONY: clean \
160169
test test-loadable test-python test-npm test-deno \
161170
loadable loadable-release \
162171
python python-release \
163172
datasette datasette-release \
164173
static static-release \
165174
debug release \
166-
format version \
167-
npm deno
175+
format version publish-release \
176+
npm deno ruby

bindings/ruby/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.gem

bindings/ruby/Gemfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source "https://rubygems.org"
2+
3+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4+
5+
gemspec

bindings/ruby/Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require "bundler/gem_tasks"
2+
task :default => :spec

bindings/ruby/lib/sqlite_regex.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require "version"
2+
3+
module SqliteRegex
4+
class Error < StandardError; end
5+
def self.regex_loadable_path
6+
File.expand_path('../regex0', __FILE__)
7+
end
8+
def self.load(db)
9+
db.load_extension(self.regex_loadable_path)
10+
end
11+
end

bindings/ruby/lib/version.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# automatically generated, do not edit by hand.
2+
module SqliteRegex
3+
VERSION = ""
4+
end

bindings/ruby/lib/version.rb.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# automatically generated, do not edit by hand.
2+
module SqliteRegex
3+
VERSION = "${VERSION}"
4+
end

bindings/ruby/sqlite_regex.gemspec

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
lib = File.expand_path("../lib", __FILE__)
3+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4+
require "version"
5+
6+
Gem::Specification.new do |spec|
7+
spec.name = "sqlite-regex"
8+
spec.version = SqliteRegex::VERSION
9+
spec.authors = ["Alex Garcia"]
10+
spec.email = ["alexsebastian.garcia@gmail.com"]
11+
12+
spec.summary = "a"
13+
spec.description = "b"
14+
spec.homepage = "https://github.com/asg017/sqlite-regex"
15+
spec.license = "MIT"
16+
17+
# The --platform flag would work in most cases, but on a GH action
18+
# linux runner, it would set platform to "ruby" and not "x86-linux".
19+
# Setting this to Gem::Platform::CURRENT
20+
spec.platform = ENV['PLATFORM']
21+
22+
if spec.respond_to?(:metadata)
23+
24+
spec.metadata["homepage_uri"] = spec.homepage
25+
spec.metadata["source_code_uri"] = spec.homepage
26+
spec.metadata["changelog_uri"] = spec.homepage
27+
else
28+
raise "RubyGems 2.0 or newer is required to protect against " \
29+
"public gem pushes."
30+
end
31+
32+
spec.files = Dir["lib/*.rb"] + Dir.glob('lib/*.{so,dylib,dll}')
33+
34+
spec.require_paths = ["lib"]
35+
36+
spec.add_development_dependency "bundler", "~> 1.17"
37+
spec.add_development_dependency "rake", "~> 10.0"
38+
end

0 commit comments

Comments
 (0)