Skip to content
This repository was archived by the owner on Aug 21, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: Ruby ${{ matrix.ruby }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
ruby: ['3.2', '3.3']
os: [ubuntu-24.04, ubuntu-24.04-arm]
include:
- ruby: '3.3'
os: macos-14

steps:
- uses: actions/checkout@v4

- name: Install GDAL (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libgdal-dev gdal-bin gdal-data pkg-config

- name: Install GDAL (macOS)
if: runner.os == 'macOS'
run: brew install gdal pkg-config

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Compile and test
run: bundle exec rake spec

- name: Show linked GDAL
run: |
gdal-config --version
gdal-config --libs
bundle exec ruby -Ilib -e "require 'gdal'; puts Gdal::Ruby::VERSION"
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Release

on:
push:
branches: [main]

permissions:
contents: write
packages: write
pull-requests: write

concurrency:
group: release-main
cancel-in-progress: false

jobs:
release-please:
name: Release please
runs-on: ubuntu-24.04
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json

publish:
name: Publish gem to GitHub Packages
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Install GDAL build deps
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libgdal-dev gdal-bin gdal-data pkg-config

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true

- name: Verify compile and specs
run: bundle exec rake spec

- name: Build gem
run: |
gem build gdal.gemspec
ls -la gdal-*.gem

- name: Publish to GitHub Packages
env:
GEM_HOST_API_KEY: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p ~/.gem
printf '%s\n' '---' ":github: ${GEM_HOST_API_KEY}" > ~/.gem/credentials
chmod 0600 ~/.gem/credentials
gem push --key github --host https://rubygems.pkg.github.com/fulcrumapp gdal-*.gem

- name: Attach gem to GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "${{ needs.release-please.outputs.tag_name }}" gdal-*.gem --clobber
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ lib/bundler/man
pkg
rdoc
spec/reports
spec/examples.txt
test/tmp
test/version_tmp
tmp
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "3.1.0"
}
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 3.3.4
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

38 changes: 35 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
# Changelog

## [3.1.0](https://github.com/fulcrumapp/gdal-ruby/compare/v3.0.0...v3.1.0) (2026-07-29)

### Features

* publish to GitHub Packages with release-please on main
* multi-arch GitHub Actions CI (ubuntu amd64/arm64, macOS arm64)
* modernize gemspec metadata and require Ruby >= 3.1
* add fixture-based specs covering Fulcrum shapefile import call surface

### Bug Fixes

* align in-repo version with the 3.x line Fulcrum already locks
* silence Ruby 3.2+ SWIG `T_DATA` allocator warnings on require
* compile against GDAL 3.13 (`CSLConstList` const-correctness, `ABS` shim)
* stop passing `-std=c++17` into the pure-C `gdalconst` extension

### Documentation

* document multi-arch limits, Packages install, and rgeo-shapefile migration path
* remove obsolete Travis CI configuration

## [3.0.0](https://github.com/fulcrumapp/gdal-ruby/compare/v2.0.0...v3.0.0) (2020-04-16)

* RubyGems release used by Fulcrum (`~> 3.0.0`); version file in git had drifted to 2.0.0

## [2.0.0](https://github.com/fulcrumapp/gdal-ruby/compare/v1.0.0...v2.0.0) (2019-06-18)

* Fix GDAL 2.x compatibility

## v1.0.0

* Regenerated bindings using GDAL 1.10.1 sources and SWIG 3.0.5
* Patch for ruby 2.2.1 (Thanks @aleksejleonov and @johnjohndoe) (Issue #5)
* Fix symbol conflicts when requiring both `gdal-ruby/gdal` and `gdal-ruby/ogr` with `get_driver_by_name` and other functions (Issue #2)
* Since the symbol conflicts are now fixed, `gdal`, `ogr`, `osr` and `gdalconst` are now `require`'d be default (Issue #2)
* Patch for ruby 2.2.1
* Fix symbol conflicts between gdal and ogr modules

## v0.0.7

* Fix for building on ruby versions where `$CXXFLAGS` isn't defined
123 changes: 82 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,107 @@
# gdal-ruby [![Build Status](https://secure.travis-ci.org/zhm/gdal-ruby.png)](http://travis-ci.org/zhm/gdal-ruby)
# gdal-ruby

Native bindings for GDAL/OGR for ruby. The GDAL repository contains ruby bindings
in the `swig/ruby` directory, but they aren't compiled or installed with default
installations of GDAL. In addition to not typically being installed, the GDAL build
system places the files in a global ruby directory which can cause some problems since
it's not the way other ruby libraries are typically installed. This gem simply turns
the ruby bindings from the GDAL repo into a gem which can be easily managed like all
of the other dependencies in your application. This simplifies the process of being
able to switch between versions of ruby and use bundler to manage the extension. Also
this gem enables you to install GDAL from the standard package managers that don't
include the ruby bindings.
[![CI](https://github.com/fulcrumapp/gdal-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/fulcrumapp/gdal-ruby/actions/workflows/ci.yml)

## Installation
Fulcrum’s internal fork of native GDAL/OGR bindings for Ruby.

You will first need to install GDAL. There are several ways to install it, but the
easiest way is using a package manager.
> **Status:** maintenance / compatibility shim. Upstream OSGeo GDAL no longer
> ships Ruby SWIG bindings. This gem vendors historical SWIG output and links
> against the system `libgdal`. For new shapefile import/export prefer
> [`rgeo-shapefile`](https://github.com/rgeo/rgeo-shapefile) (Fulcrum already
> uses `rgeo`). Keeping this gem is about API continuity, not greenfield design.

OS X:
## Why this is hard

brew install gdal
| Problem | Detail |
|--------|--------|
| Abandoned upstream Ruby bindings | No supported regenerate path from current GDAL |
| Native extension + system GDAL | Build needs matching headers/`gdal-config` per arch |
| Multi-arch | x86_64 and arm64 each need a successful compile against arch-native `libgdal` |
| Oversized surface | ~51k lines of generated C/C++ for a tiny Fulcrum call site |

Ubuntu:
Publishing to GitHub Packages does **not** by itself solve multi-arch: the
default artifact is a **source gem** that still compiles on install. Prebuilt
platform gems are a separate, costly project (`rake-compiler-dock`).

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install libgdal-dev
## Requirements

Add this line to your application's Gemfile:
- Ruby `>= 3.1`
- System GDAL development package (`libgdal-dev` / Homebrew `gdal`)
- `pkg-config` and a C++ toolchain

gem 'gdal'
Verified CI targets: Ubuntu 24.04 amd64 + arm64, macOS 14 arm64, Ruby 3.2/3.3.

And then execute:
## Install (GitHub Packages)

$ bundle
This gem is published to the Fulcrum GitHub Packages RubyGems registry on
release (merge to `main` via release-please).

Or install it yourself as:
Bundler (`~/.bundle/config` or CI env):

$ gem install gdal

Installing on Mac using The Framework way GDAL :

- Download and install GDAL Complete dmg from [kyngchaos](http://www.kyngchaos.com/software/frameworks).
```bash
bundle config set --global rubygems.pkg.github.com fulcrumapp:TOKEN
# or: BUNDLE_RUBYGEMS__PKG__GITHUB__COM=fulcrumapp:${GITHUB_TOKEN}
```

- Export path ` export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH ` in your bash or zsh profile
```ruby
# Gemfile
source "https://rubygems.pkg.github.com/fulcrumapp" do
gem "gdal", "~> 3.1"
end
```

- Verify the installation ` gdal-config --version `
System GDAL must still be present at `bundle install` / extension compile time.

- Install the gem using:

` $ gem install gdal -- --with-gdal-lib=/Library/Frameworks/GDAL.framework/unix/lib --with-gdal-includes=/Library/Frameworks/GDAL.framework/Versions/Current/Headers/ `
### Local / source install

```bash
# macOS
brew install gdal

# Debian/Ubuntu
sudo apt-get install -y libgdal-dev gdal-bin gdal-data pkg-config

bundle install
bundle exec rake spec
```

## Usage

To test it out:
```ruby
require "gdal"

puts Gdal::Ogr
.create_geometry_from_wkt("POINT (30 10)")
.export_to_json
```

Fulcrum production usage today is essentially shapefile open → read fields →
`export_to_json` in `Import::Formats::Shapefile`.

## Release automation

On every merge to `main`:

1. [release-please](https://github.com/googleapis/release-please) opens/updates a
Release PR from conventional commits (`feat:`, `fix:`, `chore:` …).
2. When that Release PR merges, Actions:
- tags `vX.Y.Z`
- builds the gem
- pushes to `https://rubygems.pkg.github.com/fulcrumapp`
- attaches the `.gem` to the GitHub Release

Version source of truth: `lib/gdal-ruby/version.rb`.

$ ruby -e "require 'gdal-ruby/ogr'; puts Gdal::Ogr.create_geometry_from_wkt('POINT (30 10)').export_to_json"
## Recommended long-term direction

The best documentation for right now is the [autotest](http://trac.osgeo.org/gdal/browser/trunk/autotest/ruby/ogr) code in the GDAL source tree. You can see various
patterns for accessing files and using the OGR API from the autotest sources.
1. **Preferred:** remove this dependency from Fulcrum; implement shapefile import
with `rgeo-shapefile` + existing RGeo stack (true multi-arch, no SWIG).
2. **If GDAL formats beyond shapefile are required:** shell out to `ogr2ogr`
(`gdal-bin` already in Fulcrum images) or evaluate `ffi-gdal`.
3. **Do not** invest in full SWIG regeneration against modern GDAL without a
strong second consumer.

## License

This gem is BSD. The .c and .cpp files in the ext/gdal-ruby directory are from GDAL. For more info,
See `ext/gdal-ruby/LICENSE` or visit [gdal.org](http://www.gdal.org/).
BSD. Generated sources under `ext/gdal-ruby` come from GDAL; see
`ext/gdal-ruby/LICENSE`.
7 changes: 4 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ Rake::ExtensionTask.new('gdal-ruby/gdalconst') do |ext|
end

RSpec::Core::RakeTask.new(:spec) do |spec|
Rake::Task['compile'].invoke
spec.pattern = FileList['spec/**/*_spec.rb']
Rake::Task["compile"].invoke
spec.pattern = FileList["spec/**/*_spec.rb"]
spec.rspec_opts = "--require spec_helper --format documentation"
end

task :default => :spec
task default: :spec
Loading
Loading