Skip to content
Draft
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
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
password: GrandMaster
database: jedi_order
port: 34837
postgres-version: 17
postgres-version: 15
postgis_version: 3.5.0
id: postgres

Expand All @@ -82,3 +82,9 @@ jobs:
if: matrix.os == 'windows-latest'
run: |
psql -v ON_ERROR_STOP=1 -c "SELECT PostGIS_Full_Version();" "${{ steps.postgres.outputs.connection-uri }}" | findstr /C:"POSTGIS=3.5.0 3.5.0"

- name: Verify PostGIS 3.5.0 installation on macOS
if: matrix.os == 'macos-latest'
run: |
psql -v ON_ERROR_STOP=1 -c "SELECT PostGIS_Full_Version();" "${{ steps.postgres.outputs.connection-uri }}" | grep "3.5.0"

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ steps:
| database | The database name to setup and grant permissions to created user. | `postgres` |
| port | The server port to listen on. | `5432` |
| postgres-version | The PostgreSQL version to install. | `17` |
| postgis_version | **(Windows only)** The PostGIS version to installed. | By default (empty), will use the latest. See available versions [here](https://download.osgeo.org/postgis/windows/). If set, must use the entire version string like `3.3.3` |
| postgis_version | **(Windows and macOS only)** The PostGIS version to install. | By default (empty), will use the latest. See available versions [here](https://download.osgeo.org/postgis/windows/). If set, must use the entire version string like `3.3.3` |
| cached-dir | Where should the temporary downloads be placed. Used to download and cache PostGIS binary. | `downloads` |

#### Outputs
Expand Down
64 changes: 63 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,73 @@ runs:
sudo apt-get install postgresql-$PG_VERSION-postgis-3
shell: bash

- name: Check PostgreSQL version (macOS)
if: runner.os == 'macOS'
id: pg-version-mac
shell: bash
run: |
# Get major version using psql
PG_VERSION=$(psql -t -A -c "SELECT split_part(version(), ' ', 2)" '${{ steps.pg.outputs.connection-uri }}' | cut -d. -f1)
echo "Found PostgreSQL major version: $PG_VERSION"

# Output version for next steps
echo "version=$PG_VERSION" >> $GITHUB_OUTPUT

- name: Setup PostgreSQL environment (macOS)
if: runner.os == 'macOS'
shell: bash
run: |
# Get PostgreSQL installation path using brew
PG_PREFIX=$(brew --prefix postgresql@${{ steps.pg-version-mac.outputs.version }})
echo "PostgreSQL prefix: $PG_PREFIX"

# Set environment variables
echo "PATH=$PG_PREFIX/bin:$PATH" >> $GITHUB_ENV
echo "LDFLAGS=-L$PG_PREFIX/lib" >> $GITHUB_ENV
echo "CPPFLAGS=-I$PG_PREFIX/include" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=$PG_PREFIX/lib/pkgconfig" >> $GITHUB_ENV

- name: Install PostGIS on macOS
if: runner.os == 'macOS'
shell: bash
run: brew install postgis
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: true
HOMEBREW_NO_INSTALL_UPGRADE: true
run: |
# If no version specified, install latest
if [[ -z "${{ inputs.postgis_version }}" ]]; then
brew install postgis -v
exit 0
fi

# Read version mapping from JSON file
FORMULA_URL=$(jq -r '."${{ inputs.postgis_version }}"' ${GITHUB_ACTION_PATH}/postgis-macos-versions.json)

if [[ "$FORMULA_URL" == "null" ]]; then
echo "Error: PostGIS version ${{ inputs.postgis_version }} is not supported on macOS"
exit 1
fi

# Download formula file
if ! wget "$FORMULA_URL" -O ./postgis.rb; then
echo "Error: Failed to download formula from $FORMULA_URL"
exit 1
fi

# Replace all postgresql@X references with detected version
sed -i '' 's/postgresql@[0-9]*/postgresql@${{ steps.pg-version-mac.outputs.version }}/g' ./postgis.rb

# Show the entire modified formula
echo "=== Modified formula content ==="
cat ./postgis.rb
echo "==========================="

# Install from local file
brew install ./postgis.rb -v -s

# Cleanup
rm -f ./postgis.rb

- name: Detect PostgreSQL Version (Windows)
if: runner.os == 'Windows'
id: pg-version
Expand Down
8 changes: 8 additions & 0 deletions postgis-macos-versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"3.5.2": "https://github.com/Homebrew/homebrew-core/raw/0e8cf73743fc1b148182ada18cbd1ea586e8b638/Formula/p/postgis.rb",
"3.5.1": "https://github.com/Homebrew/homebrew-core/raw/a78958a211e79d151309de3038d20add73306d6c/Formula/p/postgis.rb",
"3.5.0": "https://github.com/Homebrew/homebrew-core/raw/5975ad00882d998b3e1ef1fb2906000f23f18466/Formula/p/postgis.rb",
"3.4.3": "https://github.com/Homebrew/homebrew-core/raw/2858d71fabde44101eeb2a7bfbcf3b5ca2c2aa76/Formula/p/postgis.rb",
"3.4.2": "https://github.com/Homebrew/homebrew-core/raw/b1dbe7afb89d1860ed459b57d4e631de7c902462/Formula/p/postgis.rb",
"3.3.4": "https://github.com/Homebrew/homebrew-core/raw/fc8e7c36c7906eddd94ebf5109d57756a073f50f/Formula/p/postgis.rb"
}
Loading