Release #5
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: | |
workflow_dispatch: | |
inputs: | |
version: | |
type: string | |
description: Version | |
required: true | |
tag: | |
type: string | |
description: Tag | |
required: true | |
concurrency: | |
group: ${{ github.ref }}-${{ github.workflow }} | |
cancel-in-progress: true | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 | |
SCCACHE_GHA_ENABLED: true | |
RUSTC_WRAPPER: sccache | |
RUSTFLAGS: "-Dwarnings" | |
permissions: | |
contents: write | |
pull-requests: read | |
jobs: | |
semver: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/github-script@v7 | |
with: | |
script: | | |
const r = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/; | |
if (!r.test("${{ github.event.inputs.version }}")) { | |
core.setFailed(`Action failed with an invalid semver.`); | |
} | |
binary: | |
strategy: | |
matrix: | |
version: [12, 13, 14, 15, 16] | |
arch: ["x86_64", "aarch64"] | |
runs-on: ubuntu-20.04 | |
env: | |
SEMVER: ${{ github.event.inputs.version }} | |
VERSION: ${{ matrix.version }} | |
ARCH: ${{ matrix.arch }} | |
needs: ["semver"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Environment | |
run: | | |
sudo apt-get remove -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' '^mono-llvm.*' | |
sudo apt-get purge -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' '^mono-llvm.*' | |
sudo apt-get update | |
sudo apt-get install -y build-essential crossbuild-essential-arm64 | |
sudo apt-get install -y qemu-user-static | |
echo 'target.aarch64-unknown-linux-gnu.linker = "aarch64-linux-gnu-gcc"' | tee ~/.cargo/config.toml | |
rustup target add aarch64-unknown-linux-gnu | |
- name: Set up Sccache | |
uses: mozilla-actions/[email protected] | |
- name: Set up Cache | |
uses: actions/cache/restore@v4 | |
id: cache | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ github.job }}-${{ hashFiles('./Cargo.lock') }}-${{ matrix.version }}-${{ matrix.arch }} | |
- name: Set up Pgrx | |
run: | | |
# pg_config | |
mkdir -p ~/.pg_config | |
touch ~/.pg_config/pg_config | |
chmod 777 ~/.pg_config/pg_config | |
echo "#!/usr/bin/env bash" >> ~/.pg_config/pg_config | |
echo "$(pwd)/tools/pg_config.sh \"\$@\" < $(pwd)/vendor/pg_config/pg${VERSION}_${ARCH}-unknown-linux-gnu.txt" >> ~/.pg_config/pg_config | |
mkdir -p ~/.pgrx && echo "configs.pg$VERSION=\"$HOME/.pg_config/pg_config\"" > ~/.pgrx/config.toml | |
# pgrx_binding | |
mkdir -p ~/.pgrx_binding | |
cp ./vendor/pgrx_binding/pg${VERSION}_$(uname --machine)-unknown-linux-gnu.rs ~/.pgrx_binding/pg${VERSION}_raw_bindings.rs | |
echo PGRX_TARGET_INFO_PATH_PG$VERSION=$HOME/.pgrx_binding >> "$GITHUB_ENV" | |
- name: Build | |
run: | | |
cargo build --lib --features pg$VERSION --release --target $ARCH-unknown-linux-gnu | |
./tools/schema.sh --features pg$VERSION --release --target $ARCH-unknown-linux-gnu | expand -t 4 > ./target/pg_bestmatch--$SEMVER.sql | |
- name: Package | |
run: | | |
export PLATFORM=$(echo $ARCH | sed 's/aarch64/arm64/; s/x86_64/amd64/') | |
./scripts/package.sh | |
- name: Upload | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
export TAG=${{ github.event.inputs.tag }} | |
export PLATFORM=$(echo $ARCH | sed 's/aarch64/arm64/; s/x86_64/amd64/') | |
gh release upload --clobber $TAG ./build/pg_bestmatch-pg${VERSION}_${ARCH}-unknown-linux-gnu_${SEMVER}.zip | |
gh release upload --clobber $TAG ./build/postgresql-${VERSION}-pg-bestmatch_${SEMVER}_${PLATFORM}.deb | |
- name: Post Set up Cache | |
uses: actions/cache/save@v4 | |
if: ${{ !steps.cache.outputs.cache-hit }} | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ github.job }}-${{ hashFiles('./Cargo.lock') }}-${{ matrix.version }}-${{ matrix.arch }} |