feat: allow changing extension schema #29
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
# Sequence of patterns matched against refs/tags | |
tags: | |
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | |
permissions: | |
contents: write | |
jobs: | |
release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
outputs: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: softprops/action-gh-release@v1 | |
id: create-release | |
with: | |
generate_release_notes: true | |
build-linux-gnu: | |
name: release artifacts | |
needs: | |
- release | |
strategy: | |
matrix: | |
extension_name: | |
- supautils | |
postgres: [13, 14, 15, 16] | |
box: | |
- { runner: ubuntu-20.04, arch: amd64 } | |
- { runner: arm-runner, arch: arm64 } | |
runs-on: ${{ matrix.box.runner }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: build release artifacts | |
run: | | |
# Add postgres package repo | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | |
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null | |
sudo apt-get update | |
# Install requested postgres version | |
sudo apt-get install -y --no-install-recommends postgresql-${{ matrix.postgres }} postgresql-server-dev-${{ matrix.postgres }} | |
# Ensure installed pg_config is first on path | |
export PATH="/usr/lib/postgresql/${{ matrix.postgres }}/bin:$PATH" | |
# Install supautils dependencies | |
sudo apt-get install -y --no-install-recommends libicu-dev | |
# Build supautils | |
make | |
# name of the package directory before packaging | |
package_dir=${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu | |
# Copy files into directory structure | |
mkdir -p ${package_dir}/usr/lib/postgresql/lib | |
mkdir -p ${package_dir}/var/lib/postgresql/extension | |
cp *.so ${package_dir}/usr/lib/postgresql/lib | |
# symlinks to Copy files into directory structure | |
mkdir -p ${package_dir}/usr/lib/postgresql/${{ matrix.postgres }}/lib | |
cd ${package_dir}/usr/lib/postgresql/${{ matrix.postgres }}/lib | |
cp -s ../../lib/*.so . | |
cd ../../../../../.. | |
mkdir -p ${package_dir}/usr/share/postgresql/${{ matrix.postgres }}/extension | |
cd ${package_dir}/usr/share/postgresql/${{ matrix.postgres }}/extension | |
cd ../../../../../.. | |
# Create install control file | |
extension_version=${{ github.ref_name }} | |
# strip the leading v | |
deb_version=${extension_version:1} | |
mkdir -p ${package_dir}/DEBIAN | |
touch ${package_dir}/DEBIAN/control | |
echo 'Package: ${{ matrix.extension_name }}' >> ${package_dir}/DEBIAN/control | |
echo 'Version:' ${deb_version} >> ${package_dir}/DEBIAN/control | |
echo 'Architecture: ${{ matrix.box.arch }}' >> ${package_dir}/DEBIAN/control | |
echo 'Maintainer: supabase' >> ${package_dir}/DEBIAN/control | |
echo 'Description: A PostgreSQL extension' >> ${package_dir}/DEBIAN/control | |
# Create deb package | |
sudo chown -R root:root ${package_dir} | |
sudo chmod -R 00755 ${package_dir} | |
sudo dpkg-deb --build --root-owner-group ${package_dir} | |
- name: Get upload url | |
run: echo UPLOAD_URL=$(curl --silent https://api.github.com/repos/${{ github.repository }}/releases/latest | jq .upload_url --raw-output) >> $GITHUB_ENV | |
- name: Upload release asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release.outputs.upload_url }} | |
asset_path: ./${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu.deb | |
asset_name: ${{ matrix.extension_name }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu.deb | |
asset_content_type: application/vnd.debian.binary-package |