Publish #22
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: Publish | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'tag name (semver without v-prefix)' | |
required: true | |
type: string | |
concurrency: | |
group: ${{ github.ref }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
semver: | |
runs-on: ubuntu-latest | |
outputs: | |
SEMVER: ${{ steps.semver.outputs.SEMVER }} | |
steps: | |
- uses: actions/github-script@v7 | |
id: semver | |
with: | |
script: | | |
const tag = "${{ github.event.inputs.tag }}" || "${{ github.event.release.tag_name }}"; | |
console.log(`Tag: ${tag}`); | |
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(tag)) { | |
core.setFailed(`Action failed with an invalid semver.`); | |
} | |
core.setOutput('SEMVER', tag); | |
build: | |
runs-on: ubuntu-latest | |
needs: ["semver"] | |
strategy: | |
matrix: | |
version: ["14", "15", "16", "17"] | |
arch: ["x86_64", "aarch64"] | |
env: | |
PGRX_IMAGE: "ghcr.io/tensorchord/vectorchord-pgrx:0.12.8" | |
SEMVER: ${{ needs.semver.outputs.SEMVER }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Configure sccache | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const url = process.env.ACTIONS_CACHE_URL || ''; | |
const token = process.env.ACTIONS_RUNTIME_TOKEN || ''; | |
core.exportVariable( | |
'CACHE_ENVS', | |
`-e CARGO_INCREMENTAL=0 -e SCCACHE_GHA_ENABLED=true -e RUSTC_WRAPPER=sccache -e ACTIONS_CACHE_URL=${url} -e ACTIONS_RUNTIME_TOKEN=${token}`, | |
); | |
- name: Set up pgrx docker images and permissions | |
run: | | |
docker pull $PGRX_IMAGE | |
echo "Default user: $(id -u):$(id -g)" | |
sudo chmod -R 777 . | |
- name: Build | |
env: | |
VERSION: ${{ matrix.version }} | |
ARCH: ${{ matrix.arch }} | |
PLATFORM: ${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }} | |
PROFILE: "release" | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
docker run --rm -v .:/workspace $CACHE_ENVS $PGRX_IMAGE build --lib --features pg${{ matrix.version }} --target ${{ matrix.arch }}-unknown-linux-gnu --profile $PROFILE | |
docker run --rm -v .:/workspace $CACHE_ENVS --entrypoint bash -e SEMVER=${SEMVER} $PGRX_IMAGE ./tools/schema.sh --features pg${{ matrix.version }} --target ${{ matrix.arch }}-unknown-linux-gnu --profile $PROFILE | |
./tools/package.sh | |
ls ./build | |
gh release upload --clobber $SEMVER ./build/vchord-pg${VERSION}_${SEMVER}_${PLATFORM}.deb | |
gh release upload --clobber $SEMVER ./build/vchord-pg${VERSION}_${ARCH}-unknown-linux-gnu_${SEMVER}.zip | |
docker: | |
runs-on: ubuntu-latest | |
needs: ["semver", "build"] | |
strategy: | |
matrix: | |
version: ["14", "15", "16", "17"] | |
env: | |
SEMVER: ${{ needs.semver.outputs.SEMVER }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
mkdir -p build | |
for arch in amd64 arm64; do | |
gh release download $SEMVER --pattern "vchord-pg${{ matrix.version }}_${SEMVER}_${arch}.deb" --output ./build/vchord-pg${{ matrix.version }}_${SEMVER}_${arch}.deb | |
done | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERIO_USERNAME }} | |
password: ${{ secrets.DOCKERIO_TOKEN }} | |
- name: Push binary release to Docker Registry | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
platforms: "linux/amd64,linux/arm64" | |
file: ./docker/binary.Dockerfile | |
tags: tensorchord/vchord-binary:pg${{ matrix.version }}-v${{ env.SEMVER }} | |
build-args: | | |
PG_VERSION=${{ matrix.version }} | |
SEMVER=${{ env.SEMVER }} | |
- name: Push PostgreSQL release to Docker Registry | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
platforms: "linux/amd64,linux/arm64" | |
file: ./docker/Dockerfile | |
tags: tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }} | |
build-args: | | |
PG_VERSION=${{ matrix.version }} | |
SEMVER=${{ env.SEMVER }} | |
PGVECTOR=0.8.0 | |
- name: Login to modelzai Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERIO_MODELZ_USERNAME }} | |
password: ${{ secrets.DOCKERIO_MODELZ_TOKEN }} | |
- name: Build and push Enterprise image to Docker Registry | |
uses: docker/build-push-action@v6 | |
if: ${{ matrix.version != '17' }} | |
with: | |
context: ./docker/pg-cnpg | |
push: true | |
platforms: "linux/amd64" | |
file: ./docker/pg-cnpg/Dockerfile | |
build-args: | | |
PG_MAJOR=${{ matrix.version }} | |
SEMVER=${{ env.SEMVER }} | |
LIB_DIR=/usr/lib/x86_64-linux-gnu | |
TARGETARCH=amd64 | |
PGVECTOR=0.8.0 | |
tags: modelzai/vchord-cnpg:${{ matrix.version }}-v${{ env.SEMVER }} | |
test: | |
name: Run tests | |
runs-on: | |
- ubuntu-latest | |
needs: ["semver", "build", "docker"] | |
strategy: | |
matrix: | |
version: [14, 15, 16] | |
platform: ["amd64"] | |
container: | |
image: modelzai/vchord-cnpg:${{ matrix.version }}-v${{ needs.semver.outputs.SEMVER }} | |
options: --user root | |
credentials: | |
username: ${{ secrets.DOCKERIO_MODELZ_USERNAME }} | |
password: ${{ secrets.DOCKERIO_MODELZ_TOKEN }} | |
env: | |
PGHOST: "localhost" | |
PGPORT: "5432" | |
PGDATABASE: "postgres" | |
PGUSER: "postgres" | |
PGPASSWORD: "postgres" | |
POSTGRES_PASSWORD: "password" | |
PGDATA: "/var/lib/postgresql/data2" | |
steps: | |
- name: Install all extensions in registry | |
# Entrypoint is overwritten by GitHub Action. We need to execute it manually in order to start Postgres. | |
# More information here https://github.com/actions/runner/issues/1964 | |
run: | | |
bash /usr/local/bin/docker-entrypoint.sh postgres & | |
sleep 5 | |
curl https://registry.pgtrunk.io/extensions/all | jq -r ".[] | .name" > /tmp/extensions.txt | |
trunk-install.sh | tee /tmp/output.txt | |
cat /tmp/output.txt | |