Skip to content

Update docs

Update docs #5

# workflows/publish-pg_analytics-macos.yml
#
# Publish pg_analytics (macOS)
# Build and publish the pg_analytics extension for macOS as .pkg to GitHub Releases.
name: Publish pg_analytics (macOS)
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "The version to set for the pg_analytics release. This publishes the latest commit of the chosen branch and uploads it to the pre-existing GitHub Release of the provided version."
required: true
default: ""
concurrency:
group: publish-pg_analytics-macos-${{ github.head_ref || github.ref }}
cancel-in-progress: true
# Used by actions/attest-build-provenance to sign the builds
permissions:
id-token: write
attestations: write
jobs:
publish-pg_analytics:
name: Publish pg_analytics for PostgreSQL ${{ matrix.pg_version }} on ${{ matrix.name }} arm64
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
# macOS 14 and 15 are arm-only (M1)
# https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
# macOS 14 (Sonoma)
- name: macOS 14 (Sonoma)
runner: macos-14
pg_version: 14
- name: macOS 14 (Sonoma)
runner: macos-14
pg_version: 15
- name: macOS 14 (Sonoma)
runner: macos-14
pg_version: 16
- name: macOS 14 (Sonoma)
runner: macos-14
pg_version: 17
# macOS 15 (Sequoia)
- name: macOS 15 (Sequoia)
runner: macos-15
pg_version: 14
- name: macOS 15 (Sequoia)
runner: macos-15
pg_version: 15
- name: macOS 15 (Sequoia)
runner: macos-15
pg_version: 16
- name: macOS 15 (Sequoia)
runner: macos-15
pg_version: 17
steps:
- name: Checkout code
uses: actions/checkout@v4
# We force reinstall icu4c to make sure it is in PATH
- name: Install Dependencies
run: brew reinstall icu4c
# Used to upload the release to GitHub Releases. We force install gh to make sure it is in PATH.
- name: Install GitHub CLI
run: |
brew reinstall gh
gh --version
- name: Retrieve OS & GitHub Tag Versions
id: version
run: |
if [ -z "${{ github.event.inputs.version }}" ]; then
if [[ $GITHUB_REF == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION="0.0.0"
fi
else
VERSION=${{ github.event.inputs.version }}
fi
echo "GitHub Tag Version: $VERSION"
echo "tag_version=$VERSION" >> $GITHUB_OUTPUT
echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
OS_VERSION=$(sw_vers -productVersion)
case $OS_VERSION in
15.*) OS_NAME="sequoia" ;;
14.*) OS_NAME="sonoma" ;;
*) exit 1 ;;
esac
echo "OS Version: $OS_NAME"
echo "os_version=$OS_NAME" >> $GITHUB_OUTPUT
- name: Install PostgreSQL
run: |
brew install postgresql@${{ matrix.pg_version }}
brew services start postgresql@${{ matrix.pg_version }}
echo "/opt/homebrew/opt/postgresql@${{ matrix.pg_version }}/bin" >> $GITHUB_PATH
- name: Extract pgrx Version
id: pgrx
run: |
version=$(cargo tree --depth 1 -i pgrx -p pg_analytics | head -n 1 | cut -f2 -dv)
echo version=$version >> $GITHUB_OUTPUT
- name: Install pgrx
run: cargo install --locked cargo-pgrx --version ${{ steps.pgrx.outputs.version }} --debug
- name: Initialize pgrx for Current PostgreSQL Version
run: |
PG_CONFIG_PATH="/opt/homebrew/opt/postgresql@${{ matrix.pg_version }}/bin/pg_config"
cargo pgrx init --pg${{ matrix.pg_version }}=$PG_CONFIG_PATH
- name: Package pg_analytics Extension with pgrx
run: |
PG_CONFIG_PATH="/opt/homebrew/opt/postgresql@${{ matrix.pg_version }}/bin/pg_config"
export PKG_CONFIG_PATH="/opt/homebrew/opt/icu4c/lib/pkgconfig"
export PATH="/opt/homebrew/bin:$PATH"
cargo pgrx package --pg-config $PG_CONFIG_PATH
env:
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
POSTHOG_HOST: ${{ secrets.POSTHOG_HOST }}
COMMIT_SHA: ${{ steps.version.outputs.commit_sha }}
PARADEDB_VERSION: ${{ steps.version.outputs.tag_version }}
PARADEDB_TELEMETRY: true
- name: Create .pkg Package
run: |
# Retrieve the built pg_analytics extension
mkdir archive
cp `find target/release -type f -name "pg_analytics*"` archive
ls -l archive
# Variables for directory structure and versioning
pg_version=${{ matrix.pg_version }}
tag_version=${{ steps.version.outputs.tag_version }}
package_dir="pg_analytics-${tag_version}-arm64-pg${pg_version}"
# Define Homebrew PostgreSQL paths
lib_path="lib/postgresql"
share_path="share/postgresql@${pg_version}/extension"
# Create directory structure for Homebrew
mkdir -p ${package_dir}/${lib_path}
mkdir -p ${package_dir}/${share_path}
# Copy files into the directory structure. In PostgreSQL 16 onwards, the extension is a .dylib file
if [[ "${{ matrix.pg_version }}" == "16" || "${{ matrix.pg_version }}" == "17" ]]; then
cp archive/*.dylib ${package_dir}/${lib_path}
else
cp archive/*.so ${package_dir}/${lib_path}
fi
cp archive/*.control ${package_dir}/${share_path}
cp archive/*.sql ${package_dir}/${share_path}
# Create postinstall script
mkdir -p ~/tmp/pg_analytics_postinstall_script/
postinstall_file=~/tmp/pg_analytics_postinstall_script/postinstall
cat <<EOF > $postinstall_file
#!/bin/bash
# Top-level Homebrew, used by the default Homebrew PostgreSQL formula
mkdir -p /opt/homebrew/lib/postgresql@${{ matrix.pg_version }}/
mkdir -p /opt/homebrew/share/postgresql@${{ matrix.pg_version }}/extension/
ln -sf /opt/homebrew/opt/paradedb/lib/postgresql/* /opt/homebrew/lib/postgresql@${{ matrix.pg_version }}/
ln -sf /opt/homebrew/opt/paradedb/share/postgresql@${{ matrix.pg_version }}/extension/* /opt/homebrew/share/postgresql@${{ matrix.pg_version }}/extension/
# Opt-level Homebrew, used by the other Homebrew PostgreSQL formulas
mkdir -p /opt/homebrew/opt/postgresql@${{ matrix.pg_version }}/lib/postgresql/
mkdir -p /opt/homebrew/opt/postgresql@${{ matrix.pg_version }}/share/postgresql@${{ matrix.pg_version }}/extension/
ln -sf /opt/homebrew/opt/paradedb/lib/postgresql/* /opt/homebrew/opt/postgresql@${{ matrix.pg_version }}/lib/postgresql/
ln -sf /opt/homebrew/opt/paradedb/share/postgresql@${{ matrix.pg_version }}/extension/* /opt/homebrew/opt/postgresql@${{ matrix.pg_version }}/share/postgresql@${{ matrix.pg_version }}/extension/
EOF
chmod +x ~/tmp/pg_analytics_postinstall_script/postinstall
# Create the .pkg installer
pkgbuild --root ${package_dir} \
--identifier com.paradedb.pg_analytics \
--version ${tag_version} \
--install-location /opt/homebrew/opt/paradedb \
--scripts ~/tmp/pg_analytics_postinstall_script/ \
pg_analytics@${{ matrix.pg_version }}--${tag_version}.arm64_${{ steps.version.outputs.os_version }}.pkg
- name: Sign and Attest Build Provenance
uses: actions/attest-build-provenance@v2
with:
subject-path: ./pg_analytics@${{ matrix.pg_version }}--${{ steps.version.outputs.tag_version }}.arm64_${{ steps.version.outputs.os_version }}.pkg
- name: Retrieve GitHub Release Upload URL
id: upload_url
env:
GH_TOKEN: ${{ secrets.GHA_CREATE_RELEASE_PAT }}
run: |
RESPONSE=$(gh api \
-H "Authorization: token $GH_TOKEN" \
/repos/paradedb/pg_analytics/releases/tags/v${{ steps.version.outputs.tag_version }})
echo "REST API Response: $RESPONSE"
UPLOAD_URL=$(echo "$RESPONSE" | jq -r '.upload_url' | sed 's/{.*}//')
echo "GitHub Release Upload URL is: $UPLOAD_URL"
echo "upload_url=$UPLOAD_URL" >> $GITHUB_OUTPUT
- name: Upload pg_analytics .pkg to GitHub Release
uses: shogo82148/actions-upload-release-asset@v1
with:
github_token: ${{ secrets.GHA_CREATE_RELEASE_PAT }}
upload_url: ${{ steps.upload_url.outputs.upload_url }}
asset_path: ./pg_analytics@${{ matrix.pg_version }}--${{ steps.version.outputs.tag_version }}.arm64_${{ steps.version.outputs.os_version }}.pkg
asset_name: pg_analytics@${{ matrix.pg_version }}--${{ steps.version.outputs.tag_version }}.arm64_${{ steps.version.outputs.os_version }}.pkg
overwrite: true