-
Notifications
You must be signed in to change notification settings - Fork 75
189 lines (184 loc) · 7.17 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
name: Release
on:
workflow_dispatch:
inputs:
version:
type: string
description: Version
required: true
tag:
type: string
description: Tag
required: true
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
SCCACHE_GHA_ENABLED: true
RUSTC_WRAPPER: sccache
RUSTFLAGS: "-Dwarnings"
permissions:
contents: write
pull-requests: read
jobs:
semver:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
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("${{ github.event.inputs.version }}")) {
core.setFailed(`Action failed with an invalid semver.`);
}
binary:
strategy:
matrix:
version: [14, 15, 16, 17]
arch: ["x86_64", "aarch64"]
runs-on: ubuntu-20.04
env:
SEMVER: ${{ github.event.inputs.version }}
VERSION: ${{ matrix.version }}
ARCH: ${{ matrix.arch }}
needs: ["semver"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Environment
run: |
sudo apt-get remove -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' '^mono-llvm.*'
sudo apt-get purge -y '^postgres.*' '^libpq.*' '^clang.*' '^llvm.*' '^libclang.*' '^libllvm.*' '^mono-llvm.*'
sudo apt-get update
sudo apt-get install -y build-essential crossbuild-essential-arm64
sudo apt-get install -y qemu-user-static
touch ~/.cargo/config.toml
echo 'target.aarch64-unknown-linux-gnu.linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
echo 'target.aarch64-unknown-linux-gnu.runner = ["qemu-aarch64-static", "-L", "/usr/aarch64-linux-gnu"]' >> ~/.cargo/config.toml
rustup target add x86_64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-gnu
- name: Set up Sccache
uses: mozilla-actions/[email protected]
- name: Set up Cache
uses: actions/cache/restore@v4
id: cache
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ github.job }}-${{ hashFiles('./Cargo.lock') }}-${{ matrix.version }}-${{ matrix.arch }}
- name: Build
run: |
export PGRX_PG_CONFIG_PATH=$(pwd)/vendor/pg${VERSION}_${ARCH}_debian/pg_config/pg_config
export PGRX_TARGET_INFO_PATH_PG$VERSION=$(pwd)/vendor/pg${VERSION}_${ARCH}_debian/pgrx_binding
cargo build --package pgvectors --lib --features pg$VERSION --target $ARCH-unknown-linux-gnu --release
./tools/schema.sh --features pg$VERSION --target $ARCH-unknown-linux-gnu --release | expand -t 4 > ./target/schema.sql
- name: Package
run: |
export PLATFORM=$(echo $ARCH | sed 's/aarch64/arm64/; s/x86_64/amd64/')
./scripts/package.sh
- name: Upload
env:
GH_TOKEN: ${{ github.token }}
run: |
export TAG=${{ github.event.inputs.tag }}
export PLATFORM=$(echo $ARCH | sed 's/aarch64/arm64/; s/x86_64/amd64/')
gh release upload --clobber $TAG ./build/vectors-pg${VERSION}_${ARCH}-unknown-linux-gnu_${SEMVER}.zip
gh release upload --clobber $TAG ./build/vectors-pg${VERSION}_${SEMVER}_${PLATFORM}.deb
- name: Post Set up Cache
uses: actions/cache/save@v4
if: ${{ !steps.cache.outputs.cache-hit }}
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ github.job }}-${{ hashFiles('./Cargo.lock') }}-${{ matrix.version }}-${{ matrix.arch }}
docker_binary_release:
needs: ["binary", "semver"]
strategy:
matrix:
version: [14, 15, 16, 17]
platform: ["amd64", "arm64"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download ${{ github.event.inputs.tag }} --pattern "vectors-pg${{ matrix.version }}_${{ github.event.inputs.version }}_${{ matrix.platform }}.deb" --output pgvecto-rs-binary-release.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@v2
with:
username: ${{ secrets.DOCKERIO_USERNAME }}
password: ${{ secrets.DOCKERIO_TOKEN }}
- name: Push binary release to Docker Registry
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: "linux/${{ matrix.platform }}"
file: ./docker/binary_release.Dockerfile
tags: tensorchord/pgvecto-rs-binary:pg${{ matrix.version }}-v${{ github.event.inputs.version }}-${{ matrix.platform }}
docker_release:
needs: ["docker_binary_release", "semver"]
runs-on: ubuntu-latest
strategy:
matrix:
version: [14, 15, 16, 17]
rootless: [true, false]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Variables
id: variables
uses: actions/github-script@v7
with:
script: |
if ("${{ matrix.rootless }}" == "true") {
core.setOutput('tags', "tensorchord/pgvecto-rs:pg${{ matrix.version }}-v${{ github.event.inputs.version }}-rootless");
} else {
core.setOutput('tags', "tensorchord/pgvecto-rs:pg${{ matrix.version }}-v${{ github.event.inputs.version }}");
}
- 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@v2
with:
username: ${{ secrets.DOCKERIO_USERNAME }}
password: ${{ secrets.DOCKERIO_TOKEN }}
- name: Push postgres with pgvecto.rs to Docker Registry(rootful)
if: matrix.rootless == false
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: "linux/amd64,linux/arm64"
file: ./docker/pgvecto-rs.Dockerfile
build-args: |
FROM_TAG=pg${{ matrix.version }}-v${{ github.event.inputs.version }}
POSTGRES_VERSION=${{ matrix.version }}
tags: ${{ steps.variables.outputs.tags }}
- name: Push postgres with pgvecto.rs to Docker Registry(rootless)
if: matrix.rootless == true
uses: docker/build-push-action@v4
with:
context: .
push: true
platforms: "linux/amd64,linux/arm64"
file: ./docker/pgvecto-rs-rootless.Dockerfile
build-args: |
FROM_TAG=pg${{ matrix.version }}-v${{ github.event.inputs.version }}
POSTGRES_VERSION=${{ matrix.version }}
tags: ${{ steps.variables.outputs.tags }}