Skip to content
play

GitHub Action

Setup pgvector

v1 Latest version

Setup pgvector

play

Setup pgvector

Setup pgvector in GitHub Actions

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Setup pgvector

uses: cpunion/setup-pgvector@v1

Learn more about this action in cpunion/setup-pgvector

Choose a version

Setup pgvector

GitHub Action and scripts to set up PostgreSQL with pgvector extension for vector similarity search.

Features

  • πŸš€ Quick setup of PostgreSQL with pgvector extension
  • πŸ”„ Supports both GitHub Actions and local installation
  • πŸ› οΈ Customizable PostgreSQL and pgvector versions
  • πŸ” Secure password authentication
  • 🌐 Cross-platform support: Ubuntu, Windows (MSYS2), and macOS
  • πŸ—οΈ Builds pgvector from source for maximum compatibility

Supported Platforms

The following table shows the compatibility matrix for different PostgreSQL versions and platforms:

Platform Architecture PostgreSQL 14 PostgreSQL 15 PostgreSQL 16 PostgreSQL 17
ubuntu-latest x86_64 βœ… βœ… βœ… βœ…
ubuntu-24.04 x86_64 βœ… βœ… βœ… βœ…
windows-latest x86_64 βœ… βœ… βœ… βœ…
windows-2019 x86_64 βœ… βœ… βœ… βœ…
macos-latest arm64 βœ… βœ… βœ… βœ…
macos-13 x86_64 βœ… βœ… βœ… βœ…

Quick Start

GitHub Actions

steps:
- uses: cpunion/setup-pgvector@main
  with:
    postgres-version: '17'
    postgres-user: 'myuser'
    postgres-password: 'mypassword'
    postgres-db: 'mydb'

- name: Test pgvector
  env:
    PGPASSWORD: mypassword
  run: |
    psql -h localhost -U myuser -d mydb -c 'CREATE EXTENSION vector;'

Local Installation

Method 1: Direct Installation

# Ubuntu
curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-ubuntu.sh | bash

# macOS
curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-macos.sh | bash

# Windows (MSYS2)
curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-windows.sh | bash

With custom parameters:

# Format: curl ... | bash -s [PG_VERSION] [PGVECTOR_VERSION] [PGUSER] [PGPASSWORD] [PGDATABASE]
curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-ubuntu.sh | bash -s 17 0.8.0 myuser mypassword mydb

Method 2: Clone and Run

# Ubuntu
./scripts/install-ubuntu.sh

# macOS
./scripts/install-macos.sh

# Windows (MSYS2)
./scripts/install-windows.sh

Requirements

  • Ubuntu: No additional requirements
  • Windows: MSYS2 environment
  • macOS: Homebrew
  • Git (for building pgvector)

Detailed Usage

GitHub Actions

steps:
- uses: cpunion/setup-pgvector@main
  with:
    # PostgreSQL version to install (default: 17)
    postgres-version: '17'
    # pgvector version to install (default: 0.8.0)
    pgvector-version: '0.8.0'
    # PostgreSQL user to create (default: postgres)
    postgres-user: 'myuser'
    # Password for the PostgreSQL user (default: postgres)
    postgres-password: 'mypassword'
    # Database to create (default: postgres)
    postgres-db: 'mydb'

- name: Test pgvector
  env:
    PGPASSWORD: mypassword
  run: |
    psql -h localhost -U myuser -d mydb -c 'CREATE EXTENSION vector;'
    psql -h localhost -U myuser -d mydb -c 'CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));'
    psql -h localhost -U myuser -d mydb -c "INSERT INTO items (embedding) VALUES ('[1,2,3]');"
    psql -h localhost -U myuser -d mydb -c 'SELECT * FROM items;'

Script Parameters

All installation scripts accept the following parameters:

  1. PG_VERSION (default: 17) - PostgreSQL version to install
  2. PGVECTOR_VERSION (default: 0.8.0) - pgvector version to install
  3. PGUSER (default: postgres) - PostgreSQL user to create
  4. PGPASSWORD (default: postgres) - Password for the PostgreSQL user
  5. PGDATABASE (default: postgres) - Database to create

Connection Details

After installation, you can connect to PostgreSQL using:

# Using password from environment variable
export PGPASSWORD=mypassword
psql -h localhost -U myuser -d mydb

# Or using password prompt
psql -h localhost -U myuser -d mydb

Notes

  • The scripts will install PostgreSQL if not already installed
  • The scripts will create the specified user and database if they don't exist
  • The scripts will build and install pgvector from source
  • All connections are configured to use password authentication

License

MIT