Skip to content

Commit 8530ccf

Browse files
xieyddusamoi
andcommitted
ci: Added pgxn publication workflow (#265)
fix #261 --------- Signed-off-by: xieydd <xieydd@gmail.com> Co-authored-by: usamoi <usamoi@outlook.com>
1 parent e1ab379 commit 8530ccf

4 files changed

Lines changed: 142 additions & 0 deletions

File tree

.github/workflows/pgxn.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# workflows/pgxn.yml
2+
#
3+
# Publish vchord (PGXN)
4+
# Build and publish the vchord extension to the PostgreSQL Extension Network (PGXN). This
5+
# workflow is gets triggered on a new release creation or manually via the GitHub UI.
6+
7+
name: Publish vchord to PGXN
8+
9+
on:
10+
release:
11+
types: [created]
12+
workflow_dispatch:
13+
inputs:
14+
tag:
15+
description: "tag name (semver without v-prefix)"
16+
required: true
17+
type: string
18+
19+
jobs:
20+
semver:
21+
runs-on: "ubuntu-latest"
22+
23+
steps:
24+
- name: Semver
25+
id: semver
26+
uses: actions/github-script@v7
27+
with:
28+
script: |
29+
const tag = "${{ github.event.inputs.tag }}" || "${{ github.event.release.tag_name }}";
30+
console.log(`Tag: ${tag}`);
31+
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-]+)*))?$/;
32+
if (!r.test(tag)) {
33+
core.setFailed(`Action failed with an invalid semver.`);
34+
}
35+
core.setOutput('SEMVER', tag);
36+
37+
outputs:
38+
SEMVER: ${{ steps.semver.outputs.SEMVER }}
39+
40+
publish:
41+
name: Publish to PGXN
42+
runs-on: ubuntu-latest
43+
needs: ["semver"]
44+
env:
45+
DISTNAME: vchord
46+
DISTVERSION: ${{ needs.semver.outputs.SEMVER }}
47+
48+
steps:
49+
- name: Checkout Git Repository
50+
uses: actions/checkout@v4
51+
52+
- name: Bundle the Release
53+
run: |
54+
# Create a PGXN-compatible zip file.
55+
sed -e "s/@DISTVERSION@/${DISTVERSION}/g" META.json.in > META.json
56+
# Create the build directory
57+
mkdir -p ./build
58+
# Output the archive to ./build/ and use DISTNAME--DISTVERSION.zip
59+
git archive --format zip --prefix "${DISTNAME}-${DISTVERSION}/" --add-file META.json -o "./build/${DISTNAME}--${DISTVERSION}.zip" HEAD
60+
echo "Release bundle created: ./build/${DISTNAME}--${DISTVERSION}.zip"
61+
62+
- name: Release on PGXN
63+
env:
64+
PGXN_USERNAME: ${{ secrets.PGXN_USERNAME }}
65+
PGXN_PASSWORD: ${{ secrets.PGXN_PASSWORD }}
66+
run: |
67+
# DISTNAME and DISTVERSION are available from the job's env context
68+
ARCHIVE_PATH="./build/${DISTNAME}--${DISTVERSION}.zip"
69+
echo "Uploading ${ARCHIVE_PATH} to PGXN..."
70+
curl --fail -sS \
71+
--user "${PGXN_USERNAME}:${PGXN_PASSWORD}" \
72+
-F "submit=Release It!" \
73+
-F "archive=@${ARCHIVE_PATH}" \
74+
-H "X-Requested-With: XMLHttpRequest" \
75+
https://manager.pgxn.org/upload

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,4 @@ jobs:
219219
--amend ghcr.io/tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}-amd64 \
220220
--amend ghcr.io/tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}-arm64
221221
docker manifest push ghcr.io/tensorchord/vchord-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}
222+

META.json.in

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "vchord",
3+
"abstract": "Scalable, fast, and disk-friendly vector search in Postgres",
4+
"description": "VectorChord (vchord) is a PostgreSQL extension designed for scalable, high-performance, and disk-efficient vector similarity search, it supports L2 distance, inner product, cosine distance and maxsim",
5+
"version": "@DISTVERSION@",
6+
"maintainer": [
7+
"TensorChord support@tensorchord.ai",
8+
"usamoi usamoi@tensorchord.ai"
9+
],
10+
"license": "agpl_3",
11+
"prereqs": {
12+
"runtime": {
13+
"requires": {
14+
"PostgreSQL": "13.0.0"
15+
}
16+
}
17+
},
18+
"provides": {
19+
"vchord": {
20+
"file": "src/lib.rs",
21+
"docfile": "README.md",
22+
"version": "@DISTVERSION@",
23+
"abstract": "Scalable, fast, and disk-friendly vector search in Postgres"
24+
}
25+
},
26+
"resources": {
27+
"homepage": "https://github.com/tensorchord/VectorChord",
28+
"bugtracker": {
29+
"web": "https://github.com/tensorchord/VectorChord/issues"
30+
},
31+
"repository": {
32+
"url": "https://github.com/tensorchord/VectorChord.git",
33+
"web": "https://github.com/tensorchord/VectorChord",
34+
"type": "git"
35+
}
36+
},
37+
"generated_by": "TensorChord",
38+
"meta-spec": {
39+
"version": "1.0.0",
40+
"url": "http://pgxn.org/meta/spec.txt"
41+
},
42+
"tags": [
43+
"vector search",
44+
"vectors",
45+
"datatype",
46+
"nearest neighbor search",
47+
"approximate nearest neighbors"
48+
]
49+
}

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
PG_CONFIG ?= $(shell which pg_config)
2+
3+
.PHONY: make package install
4+
.DEFAULT_GOAL: package
5+
6+
all: build-make package
7+
8+
build-make:
9+
mkdir -p ./build
10+
cargo build -p make
11+
cp ./target/debug/make ./build/make
12+
13+
package:
14+
PGRX_PG_CONFIG_PATH="$(PG_CONFIG)" ./build/make package -o ./build/raw
15+
16+
install:
17+
PGRX_PG_CONFIG_PATH="$(PG_CONFIG)" ./build/make install -i ./build/raw

0 commit comments

Comments
 (0)