Skip to content

changing cicd

changing cicd #8

Workflow file for this run

env:
NAME: uids
EXT_NAME: uids
PKG_NAME: uids
name: Release
on:
push:
tags: [v*]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
create-release:
name: Create release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Create Release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
build-linux-gnu:
name: Build & Release for linux
needs:
- create-release
strategy:
fail-fast: false
matrix:
postgres: [14, 15, 16]
box:
- runner: ubuntu-22.04
arch: amd64
- runner: buildjet-8vcpu-ubuntu-2204-arm
arch: arm64
runs-on: ${{ matrix.box.runner }}
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install rust
uses: dtolnay/[email protected]
- name: Install dependencies
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
sudo apt-get install -y --no-install-recommends git build-essential libpq-dev curl libreadline6-dev zlib1g-dev pkg-config cmake
sudo apt-get install -y --no-install-recommends libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache
sudo apt-get install -y --no-install-recommends clang libclang-dev llvm-dev gcc tree
# Install requested postgres version
sudo apt-get install -y postgresql-${{ matrix.postgres }} postgresql-server-dev-${{ matrix.postgres }} -y
# Ensure installed pg_config is first on path
export PATH=$PATH:/usr/lib/postgresql/${{ matrix.postgres }}/bin
cargo install cargo-pgrx --version 0.11.2 --locked
cargo pgrx init --pg${{ matrix.postgres }}=/usr/lib/postgresql/${{ matrix.postgres }}/bin/pg_config
- name: Build artifacts
run: |
# selects the pgVer from pg_config on path
# https://github.com/tcdi/pgrx/issues/288
cargo pgrx package --no-default-features --features pg${{ matrix.postgres }}
# Create installable package
mkdir archive
cp `find target/release -type f -name "${{ env.EXT_NAME }}*"` archive
# Copy files into directory structure
mkdir -p package/usr/lib/postgresql/lib
mkdir -p package/var/lib/postgresql/extension
cp archive/*.so package/usr/lib/postgresql/lib
cp archive/*.control package/var/lib/postgresql/extension
cp archive/*.sql package/var/lib/postgresql/extension
# symlinks to Copy files into directory structure
mkdir -p package/usr/lib/postgresql/${{ matrix.postgres }}/lib
cd package/usr/lib/postgresql/${{ matrix.postgres }}/lib
cp -s ../../lib/*.so .
cd ../../../../../..
mkdir -p package/usr/share/postgresql/${{ matrix.postgres }}/extension
cd package/usr/share/postgresql/${{ matrix.postgres }}/extension
cp -s ../../../../../var/lib/postgresql/extension/${{ env.EXT_NAME }}.control .
cp -s ../../../../../var/lib/postgresql/extension/${{ env.EXT_NAME }}*.sql .
cd ../../../../../..
# Create install control file
extension_version=${{ github.ref_name }}
# strip the leading v
deb_version=${extension_version:1}
mkdir -p package/DEBIAN
touch package/DEBIAN/control
echo 'Package: ${{ env.PKG_NAME }}' >> package/DEBIAN/control
echo 'Version:' ${deb_version} >> package/DEBIAN/control
echo 'Architecture: ${{ matrix.box.arch }}' >> package/DEBIAN/control
echo 'Maintainer: Pavan Sunkara' >> package/DEBIAN/control
echo 'Description: A PostgreSQL extension for ULID' >> package/DEBIAN/control
# Create deb package
sudo chown -R root:root package
sudo chmod -R 00755 package
sudo dpkg-deb -Zxz --build --root-owner-group package
- name: Upload artifacts
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./package.deb
asset_name: ${{ env.NAME }}-${{ github.ref_name }}-pg${{ matrix.postgres }}-${{ matrix.box.arch }}-linux-gnu.deb
asset_content_type: application/vnd.debian.binary-package