-
Notifications
You must be signed in to change notification settings - Fork 3
142 lines (135 loc) · 5.02 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
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
outputs:
SEMVER: ${{ steps.semver.outputs.SEMVER }}
steps:
- uses: actions/github-script@v7
id: semver
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);
build:
runs-on: ${{ matrix.runner }}
needs: ["semver"]
strategy:
matrix:
version: ["14", "15", "16", "17"]
runner: ["ubuntu-22.04", "ubuntu-22.04-arm"]
env:
PGRX_IMAGE: "ghcr.io/tensorchord/vectorchord-pgrx:0.12.9-nightly-2024-12-25"
SEMVER: ${{ needs.semver.outputs.SEMVER }}
ARCH: ${{ matrix.runner == 'ubuntu-22.04' && 'x86_64' || 'aarch64' }}
PLATFORM: ${{ matrix.runner == 'ubuntu-22.04' && 'amd64' || 'arm64' }}
steps:
- uses: actions/checkout@v4
- name: Configure sccache
uses: actions/github-script@v7
with:
script: |
const url = process.env.ACTIONS_CACHE_URL || '';
const token = process.env.ACTIONS_RUNTIME_TOKEN || '';
core.exportVariable(
'CACHE_ENVS',
`-e CARGO_INCREMENTAL=0 -e SCCACHE_GHA_ENABLED=true -e RUSTC_WRAPPER=sccache -e ACTIONS_CACHE_URL=${url} -e ACTIONS_RUNTIME_TOKEN=${token}`,
);
- name: Set up pgrx docker images and permissions
run: |
docker pull $PGRX_IMAGE
echo "Default user: $(id -u):$(id -g)"
sudo chmod -R 777 .
- name: Build
env:
GH_TOKEN: ${{ github.token }}
run: |
docker run --rm -v .:/workspace $CACHE_ENVS \
-e SEMVER=$SEMVER \
-e VERSION=${{ matrix.version }} \
-e ARCH=$ARCH \
-e PLATFORM=$PLATFORM \
$PGRX_IMAGE ./tools/package.sh
ls ./build
gh release upload --clobber $SEMVER ./build/postgresql-${{ matrix.version }}-vchord-bm25_${SEMVER}-1_${PLATFORM}.deb
gh release upload --clobber $SEMVER ./build/postgresql-${{ matrix.version }}-vchord-bm25_${SEMVER}_${ARCH}-linux-gnu.zip
docker:
runs-on: ubuntu-latest
permissions:
packages: write
needs: ["semver", "build"]
strategy:
matrix:
version: ["14", "15", "16", "17"]
env:
SEMVER: ${{ needs.semver.outputs.SEMVER }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p build
for arch in amd64 arm64; do
gh release download $SEMVER --pattern "postgresql-${{ matrix.version }}-vchord-bm25_${SEMVER}-1_${arch}.deb" --output ./build/postgresql-${{ matrix.version }}-vchord-bm25_${SEMVER}-1_${arch}.deb
done
- 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: Login to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push binary release to Docker Registry
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: "linux/amd64,linux/arm64"
file: ./docker/binary.Dockerfile
tags: |
tensorchord/vchord_bm25-binary:pg${{ matrix.version }}-v${{ env.SEMVER }}
ghcr.io/tensorchord/vchord_bm25-binary:pg${{ matrix.version }}-v${{ env.SEMVER }}
build-args: |
PG_VERSION=${{ matrix.version }}
SEMVER=${{ env.SEMVER }}
- name: Push PostgreSQL release to Docker Registry
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: "linux/amd64,linux/arm64"
file: ./docker/Dockerfile
tags: |
tensorchord/vchord_bm25-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}
ghcr.io/tensorchord/vchord_bm25-postgres:pg${{ matrix.version }}-v${{ env.SEMVER }}
build-args: |
PG_VERSION=${{ matrix.version }}
SEMVER=${{ env.SEMVER }}
VCHORD_VERSION=0.2.0