|
1 | | -# Setup pgvector Action |
| 1 | +# Setup pgvector |
2 | 2 |
|
3 | | -This action sets up [pgvector](https://github.com/pgvector/pgvector) in your GitHub Actions workflow. It uses the preinstalled PostgreSQL on GitHub runners and installs pgvector using platform-specific methods. |
| 3 | +GitHub Action and scripts to set up PostgreSQL with pgvector extension for vector similarity search. |
4 | 4 |
|
5 | | -## Usage |
| 5 | +## Features |
| 6 | + |
| 7 | +- 🚀 Quick setup of PostgreSQL with pgvector extension |
| 8 | +- 🔄 Supports both GitHub Actions and local installation |
| 9 | +- 🛠️ Customizable PostgreSQL and pgvector versions |
| 10 | +- 🔐 Secure password authentication |
| 11 | +- 🌐 Cross-platform support: Ubuntu, Windows (MSYS2), and macOS |
| 12 | +- 🏗️ Builds pgvector from source for maximum compatibility |
| 13 | + |
| 14 | +## Supported Platforms |
| 15 | + |
| 16 | +The following table shows the compatibility matrix for different PostgreSQL versions and platforms: |
| 17 | + |
| 18 | +| Platform | Architecture | PostgreSQL 14 | PostgreSQL 15 | PostgreSQL 16 | PostgreSQL 17 | |
| 19 | +|----------|-------------|:-------------:|:-------------:|:-------------:|:-------------:| |
| 20 | +| Ubuntu Latest | x86_64 | ✅ | ✅ | ✅ | ✅ | |
| 21 | +| Ubuntu 24.04 | x86_64 | ✅ | ✅ | ✅ | ✅ | |
| 22 | +| Windows Latest | x86_64 | ✅ | ✅ | ✅ | ✅ | |
| 23 | +| Windows 2019 | x86_64 | ✅ | ✅ | ✅ | ✅ | |
| 24 | +| macOS Latest | arm64 | ✅ | ✅ | ✅ | ✅ | |
| 25 | +| macOS 13 | x86_64 | ✅ | ✅ | ✅ | ✅ | |
| 26 | + |
| 27 | +## Quick Start |
| 28 | + |
| 29 | +### GitHub Actions |
6 | 30 |
|
7 | 31 | ```yaml |
8 | 32 | steps: |
9 | | -- uses: actions/checkout@v4 |
10 | | -- uses: cpunion/setup-pgvector@v1 |
| 33 | +- uses: cpunion/setup-pgvector@main |
11 | 34 | with: |
12 | | - postgres-version: '17' # optional, defaults to 17. Use 14 for ubuntu-22.04 and ubuntu-20.04 |
| 35 | + postgres-version: '17' |
| 36 | + postgres-user: 'myuser' |
| 37 | + postgres-password: 'mypassword' |
| 38 | + postgres-db: 'mydb' |
| 39 | + |
| 40 | +- name: Test pgvector |
| 41 | + env: |
| 42 | + PGPASSWORD: mypassword |
| 43 | + run: | |
| 44 | + psql -h localhost -U myuser -d mydb -c 'CREATE EXTENSION vector;' |
13 | 45 | ``` |
14 | 46 |
|
15 | | -## Inputs |
| 47 | +### Local Installation |
16 | 48 |
|
17 | | -- `postgres-version`: PostgreSQL version to use (default: '17'). Note: Use '14' for ubuntu-22.04 and ubuntu-20.04. |
| 49 | +#### Method 1: Direct Installation |
18 | 50 |
|
19 | | -## Platform Support |
| 51 | +```bash |
| 52 | +# Ubuntu |
| 53 | +curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-ubuntu.sh | bash |
20 | 54 |
|
21 | | -This action supports all major GitHub Actions platforms: |
22 | | -- Ubuntu (using postgresql-xx-pgvector package) |
23 | | -- macOS (using Homebrew) |
24 | | -- Windows (building from source using Visual Studio Build Tools) |
| 55 | +# macOS |
| 56 | +curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-macos.sh | bash |
25 | 57 |
|
26 | | -## CI Status |
| 58 | +# Windows (MSYS2) |
| 59 | +curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-windows.sh | bash |
| 60 | +``` |
27 | 61 |
|
28 | | -The action is tested on the following platforms: |
29 | | -- Ubuntu: ubuntu-latest, ubuntu-24.04 |
30 | | -- Windows: windows-latest, windows-2019 |
31 | | -- macOS: macos-latest, macos-13 |
| 62 | +With custom parameters: |
| 63 | +```bash |
| 64 | +# Format: curl ... | bash -s [PG_VERSION] [PGVECTOR_VERSION] [PGUSER] [PGPASSWORD] [PGDATABASE] |
| 65 | +curl -fsSL https://raw.githubusercontent.com/cpunion/setup-pgvector/main/scripts/install-ubuntu.sh | bash -s 17 0.8.0 myuser mypassword mydb |
| 66 | +``` |
32 | 67 |
|
33 | | -## Example workflows |
| 68 | +#### Method 2: Clone and Run |
34 | 69 |
|
35 | | -### Ubuntu |
36 | | -```yaml |
37 | | -name: Test Ubuntu |
38 | | -
|
39 | | -on: [push] |
40 | | -
|
41 | | -jobs: |
42 | | - test: |
43 | | - runs-on: ubuntu-latest # or ubuntu-22.04, ubuntu-20.04 |
44 | | - steps: |
45 | | - - uses: actions/checkout@v4 |
46 | | - - name: Setup pgvector |
47 | | - uses: cpunion/setup-pgvector@v1 |
48 | | - with: |
49 | | - postgres-version: '17' # Use '14' for ubuntu-22.04 and ubuntu-20.04 |
50 | | - - name: Create extension |
51 | | - run: | |
52 | | - sudo -u postgres psql -c 'CREATE EXTENSION vector;' |
| 70 | +```bash |
| 71 | +# Ubuntu |
| 72 | +./scripts/install-ubuntu.sh |
| 73 | + |
| 74 | +# macOS |
| 75 | +./scripts/install-macos.sh |
| 76 | + |
| 77 | +# Windows (MSYS2) |
| 78 | +./scripts/install-windows.sh |
53 | 79 | ``` |
54 | 80 |
|
55 | | -### macOS |
| 81 | +## Requirements |
| 82 | + |
| 83 | +- Ubuntu: No additional requirements |
| 84 | +- Windows: MSYS2 environment |
| 85 | +- macOS: Homebrew |
| 86 | +- Git (for building pgvector) |
| 87 | + |
| 88 | +## Detailed Usage |
| 89 | + |
| 90 | +### GitHub Actions |
| 91 | + |
56 | 92 | ```yaml |
57 | | -name: Test macOS |
58 | | -
|
59 | | -on: [push] |
60 | | -
|
61 | | -jobs: |
62 | | - test: |
63 | | - runs-on: macos-latest # or macos-13 |
64 | | - steps: |
65 | | - - uses: actions/checkout@v4 |
66 | | - - name: Setup pgvector |
67 | | - uses: cpunion/setup-pgvector@v1 |
68 | | - - name: Create extension |
69 | | - run: | |
70 | | - psql postgres -c 'CREATE EXTENSION vector;' |
| 93 | +steps: |
| 94 | +- uses: cpunion/setup-pgvector@main |
| 95 | + with: |
| 96 | + # PostgreSQL version to install (default: 17) |
| 97 | + postgres-version: '17' |
| 98 | + # pgvector version to install (default: 0.8.0) |
| 99 | + pgvector-version: '0.8.0' |
| 100 | + # PostgreSQL user to create (default: postgres) |
| 101 | + postgres-user: 'myuser' |
| 102 | + # Password for the PostgreSQL user (default: postgres) |
| 103 | + postgres-password: 'mypassword' |
| 104 | + # Database to create (default: postgres) |
| 105 | + postgres-db: 'mydb' |
| 106 | + |
| 107 | +- name: Test pgvector |
| 108 | + env: |
| 109 | + PGPASSWORD: mypassword |
| 110 | + run: | |
| 111 | + psql -h localhost -U myuser -d mydb -c 'CREATE EXTENSION vector;' |
| 112 | + psql -h localhost -U myuser -d mydb -c 'CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));' |
| 113 | + psql -h localhost -U myuser -d mydb -c "INSERT INTO items (embedding) VALUES ('[1,2,3]');" |
| 114 | + psql -h localhost -U myuser -d mydb -c 'SELECT * FROM items;' |
71 | 115 | ``` |
72 | 116 |
|
73 | | -### Windows |
74 | | -```yaml |
75 | | -name: Test Windows |
76 | | -
|
77 | | -on: [push] |
78 | | -
|
79 | | -jobs: |
80 | | - test: |
81 | | - strategy: |
82 | | - matrix: |
83 | | - os: [windows-latest, windows-2019] |
84 | | - runs-on: ${{ matrix.os }} |
85 | | - steps: |
86 | | - - uses: actions/checkout@v4 |
87 | | - - name: Setup pgvector |
88 | | - uses: cpunion/setup-pgvector@v1 |
89 | | - - name: Create extension |
90 | | - shell: cmd |
91 | | - run: | |
92 | | - psql -U postgres -c "CREATE EXTENSION vector;" |
| 117 | +### Script Parameters |
| 118 | +
|
| 119 | +All installation scripts accept the following parameters: |
| 120 | +
|
| 121 | +1. `PG_VERSION` (default: 17) - PostgreSQL version to install |
| 122 | +2. `PGVECTOR_VERSION` (default: 0.8.0) - pgvector version to install |
| 123 | +3. `PGUSER` (default: postgres) - PostgreSQL user to create |
| 124 | +4. `PGPASSWORD` (default: postgres) - Password for the PostgreSQL user |
| 125 | +5. `PGDATABASE` (default: postgres) - Database to create |
| 126 | + |
| 127 | +### Connection Details |
| 128 | + |
| 129 | +After installation, you can connect to PostgreSQL using: |
| 130 | + |
| 131 | +```bash |
| 132 | +# Using password from environment variable |
| 133 | +export PGPASSWORD=mypassword |
| 134 | +psql -h localhost -U myuser -d mydb |
| 135 | +
|
| 136 | +# Or using password prompt |
| 137 | +psql -h localhost -U myuser -d mydb |
93 | 138 | ``` |
94 | 139 |
|
| 140 | +## Notes |
| 141 | + |
| 142 | +- The scripts will install PostgreSQL if not already installed |
| 143 | +- The scripts will create the specified user and database if they don't exist |
| 144 | +- The scripts will build and install pgvector from source |
| 145 | +- All connections are configured to use password authentication |
| 146 | + |
95 | 147 | ## License |
96 | 148 |
|
97 | 149 | MIT |
0 commit comments