-
Notifications
You must be signed in to change notification settings - Fork 18
306 lines (280 loc) · 12.4 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
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 <[email protected]>
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