Publish #42
Workflow file for this run
This file contains hidden or 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" | |
| steps: | |
| - name: Semver | |
| id: semver | |
| uses: actions/github-script@v7 | |
| 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); | |
| outputs: | |
| SEMVER: ${{ steps.semver.outputs.SEMVER }} | |
| build: | |
| needs: ["semver"] | |
| strategy: | |
| matrix: | |
| version: ["13", "14", "15", "16", "17"] | |
| runner: ["ubuntu-22.04", "ubuntu-22.04-arm"] | |
| runs-on: ${{ matrix.runner }} | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| RUSTFLAGS: "-Dwarnings" | |
| steps: | |
| - name: Set up Environment | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get remove -y '^postgres.*' '^libpq.*' | |
| sudo apt-get purge -y '^postgres.*' '^libpq.*' | |
| curl --proto '=https' --tlsv1.2 -sSf https://apt.llvm.org/llvm.sh | sudo bash -s -- 18 | |
| sudo update-alternatives --install /usr/bin/clang clang $(which clang-18) 255 | |
| sudo apt-get install -y postgresql-common | |
| sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y | |
| sudo apt-get install -y postgresql-server-dev-${{ matrix.version }} | |
| sudo apt-get install -y postgresql-${{ matrix.version }} postgresql-${{ matrix.version }}-pgvector | |
| curl -fsSL https://github.com/tensorchord/pgrx/releases/download/v0.12.9/cargo-pgrx-v0.12.9-$(uname -m)-unknown-linux-musl.tar.gz | tar -xOzf - ./cargo-pgrx | install -m 755 /dev/stdin /usr/local/bin/cargo-pgrx | |
| cargo pgrx init --pg${{ matrix.version }}=$(which pg_config) | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Build | |
| env: | |
| SEMVER: ${{ needs.semver.outputs.SEMVER }} | |
| VERSION: ${{ matrix.version }} | |
| ARCH: ${{ matrix.runner == 'ubuntu-22.04' && 'x86_64' || 'aarch64' }} | |
| PLATFORM: ${{ matrix.runner == 'ubuntu-22.04' && 'amd64' || 'arm64' }} | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| cargo build --lib --features pg$VERSION --release | |
| mkdir -p ./build/zip | |
| cp -a ./sql/upgrade/. ./build/zip/ | |
| cp ./sql/install/vchord--$SEMVER.sql ./build/zip/vchord--$SEMVER.sql | |
| sed -e "s/@CARGO_VERSION@/$SEMVER/g" < ./vchord.control > ./build/zip/vchord.control | |
| cp ./target/release/libvchord.so ./build/zip/vchord.so | |
| zip ./build/postgresql-${VERSION}-vchord_${SEMVER}_${ARCH}-linux-gnu.zip -j ./build/zip/* | |
| mkdir -p ./build/deb | |
| mkdir -p ./build/deb/DEBIAN | |
| mkdir -p ./build/deb/usr/share/postgresql/$VERSION/extension/ | |
| mkdir -p ./build/deb/usr/lib/postgresql/$VERSION/lib/ | |
| for file in $(ls ./build/zip/*.sql | xargs -n 1 basename); do | |
| cp ./build/zip/$file ./build/deb/usr/share/postgresql/$VERSION/extension/$file | |
| done | |
| for file in $(ls ./build/zip/*.control | xargs -n 1 basename); do | |
| cp ./build/zip/$file ./build/deb/usr/share/postgresql/$VERSION/extension/$file | |
| done | |
| for file in $(ls ./build/zip/*.so | xargs -n 1 basename); do | |
| cp ./build/zip/$file ./build/deb/usr/lib/postgresql/$VERSION/lib/$file | |
| done | |
| echo "Package: postgresql-${VERSION}-vchord | |
| Version: ${SEMVER}-1 | |
| Section: database | |
| Priority: optional | |
| Architecture: ${PLATFORM} | |
| Maintainer: Tensorchord <support@tensorchord.ai> | |
| Description: Vector database plugin for Postgres, written in Rust, specifically designed for LLM | |
| Homepage: https://vectorchord.ai/ | |
| License: AGPL-3 or Elastic-2" \ | |
| > ./build/deb/DEBIAN/control | |
| (cd ./build/deb && md5sum usr/share/postgresql/$VERSION/extension/* usr/lib/postgresql/$VERSION/lib/*) > ./build/deb/DEBIAN/md5sums | |
| dpkg-deb --root-owner-group -Zxz --build ./build/deb/ ./build/postgresql-${VERSION}-vchord_${SEMVER}-1_${PLATFORM}.deb | |
| ls ./build | |
| gh release upload --clobber $SEMVER ./build/postgresql-${VERSION}-vchord_${SEMVER}-1_${PLATFORM}.deb | |
| gh release upload --clobber $SEMVER ./build/postgresql-${VERSION}-vchord_${SEMVER}_${ARCH}-linux-gnu.zip | |
| docker: | |
| runs-on: ${{ matrix.runner }} | |
| needs: ["semver", "build"] | |
| strategy: | |
| matrix: | |
| version: ["14", "15", "16", "17"] | |
| runner: ["ubuntu-22.04", "ubuntu-22.04-arm"] | |
| env: | |
| SEMVER: ${{ needs.semver.outputs.SEMVER }} | |
| PLATFORM: ${{ matrix.runner == 'ubuntu-22.04' && 'amd64' || 'arm64' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| mkdir -p build | |
| gh release download $SEMVER --pattern "postgresql-${{ matrix.version }}-vchord_${SEMVER}-1_${PLATFORM}.deb" --output ./build/postgresql-${{ matrix.version }}-vchord_${SEMVER}-1_${PLATFORM}.deb | |
| - 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: ${{ matrix.runner == 'ubuntu-22.04' && 'linux/amd64' || 'linux/arm64' }} | |
| file: ./docker/binary.Dockerfile | |
| provenance: false | |
| tags: tensorchord/vchord-binary:pg${{ matrix.version }}-v${{ env.SEMVER }}-${{ env.PLATFORM }} | |
| build-args: | | |
| PG_VERSION=${{ matrix.version }} | |
| SEMVER=${{ env.SEMVER }} | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Push PostgreSQL release to Docker Registry | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| platforms: ${{ matrix.runner == 'ubuntu-22.04' && 'linux/amd64' || 'linux/arm64' }} | |
| file: ./docker/Dockerfile | |
| provenance: false | |
| tags: | | |
| tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}-${{ env.PLATFORM }} | |
| ghcr.io/tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}-${{ env.PLATFORM }} | |
| build-args: | | |
| PG_VERSION=${{ matrix.version }} | |
| SEMVER=${{ env.SEMVER }} | |
| PGVECTOR=0.8.0 | |
| - name: Login to modelzai Docker Hub | |
| uses: docker/login-action@v3 | |
| 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 | |
| with: | |
| context: ./docker/pg-cnpg | |
| push: true | |
| platforms: ${{ matrix.runner == 'ubuntu-22.04' && 'linux/amd64' || 'linux/arm64' }} | |
| file: ${{ matrix.runner == 'ubuntu-22.04' && './docker/pg-cnpg/Dockerfile' || './docker/pg-cnpg/Dockerfile.arm' }} | |
| provenance: false | |
| build-args: | | |
| PG_MAJOR=${{ matrix.version }} | |
| SEMVER=${{ env.SEMVER }} | |
| LIB_DIR=${{ matrix.runner == 'ubuntu-22.04' && '/usr/lib/x86_64-linux-gnu' || '/usr/lib/aarch64-linux-gnu' }} | |
| TARGETARCH=${{ env.PLATFORM }} | |
| PGVECTOR=0.8.0 | |
| tags: modelzai/vchord-cnpg:${{ matrix.version }}-v${{ env.SEMVER }}-${{ env.PLATFORM }} | |
| create-manifests: | |
| runs-on: ubuntu-latest | |
| needs: ["semver", "build", "docker"] | |
| strategy: | |
| matrix: | |
| version: ["14", "15", "16", "17"] | |
| env: | |
| SEMVER: ${{ needs.semver.outputs.SEMVER }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERIO_USERNAME }} | |
| password: ${{ secrets.DOCKERIO_TOKEN }} | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create manifest and push | |
| run: | | |
| docker manifest create \ | |
| tensorchord/vchord-binary:pg${{ matrix.version }}-v${{ env.SEMVER }} \ | |
| --amend tensorchord/vchord-binary:pg${{ matrix.version }}-v${{ env.SEMVER }}-amd64 \ | |
| --amend tensorchord/vchord-binary:pg${{ matrix.version }}-v${{ env.SEMVER }}-arm64 | |
| docker manifest push tensorchord/vchord-binary:pg${{ matrix.version }}-v${{ env.SEMVER }} | |
| docker manifest create \ | |
| tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }} \ | |
| --amend tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}-amd64 \ | |
| --amend tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}-arm64 | |
| docker manifest push tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }} | |
| docker manifest create \ | |
| ghcr.io/tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }} \ | |
| --amend ghcr.io/tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}-amd64 \ | |
| --amend ghcr.io/tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}-arm64 | |
| docker manifest push ghcr.io/tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }} | |
| create-manifests-modelzai: | |
| runs-on: ubuntu-latest | |
| needs: ["semver", "build", "docker"] | |
| strategy: | |
| matrix: | |
| version: ["14", "15", "16", "17"] | |
| env: | |
| SEMVER: ${{ needs.semver.outputs.SEMVER }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Login to modelzai Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERIO_MODELZ_USERNAME }} | |
| password: ${{ secrets.DOCKERIO_MODELZ_TOKEN }} | |
| - name: Create manifest and push | |
| run: | | |
| docker manifest create \ | |
| modelzai/vchord-cnpg:${{ matrix.version }}-v${{ env.SEMVER }} \ | |
| --amend modelzai/vchord-cnpg:${{ matrix.version }}-v${{ env.SEMVER }}-amd64 \ | |
| --amend modelzai/vchord-cnpg:${{ matrix.version }}-v${{ env.SEMVER }}-arm64 | |
| docker manifest push modelzai/vchord-cnpg:${{ matrix.version }}-v${{ env.SEMVER }} | |
| test: | |
| name: Run tests | |
| runs-on: ${{ matrix.runner }} | |
| needs: ["semver", "build", "docker", "create-manifests"] | |
| strategy: | |
| matrix: | |
| version: [14, 15, 16, 17] | |
| runner: ["ubuntu-22.04"] | |
| 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 | |
| extension-install.sh | tee /tmp/output.txt | |
| cat /tmp/output.txt | |