Skip to content

Commit

Permalink
ci: add rust aarch64 target in release
Browse files Browse the repository at this point in the history
Signed-off-by: usamoi <[email protected]>
  • Loading branch information
usamoi committed Jun 5, 2024
1 parent 43dd5cd commit 7758ec6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
sudo apt-get install -y build-essential crossbuild-essential-arm64
sudo apt-get install -y qemu-user-static
echo 'target.aarch64-unknown-linux-gnu.linker = "aarch64-linux-gnu-gcc"' | tee ~/.cargo/config.toml
rustup target add aarch64-unknown-linux-gnu
- name: Set up Sccache
uses: mozilla-actions/[email protected]
- name: Set up Cache
Expand All @@ -71,12 +72,6 @@ jobs:
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ github.job }}-${{ hashFiles('./Cargo.lock') }}-${{ matrix.version }}-${{ matrix.arch }}
- name: Set up Clang-16
run: |
sudo sh -c 'echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-16 main" >> /etc/apt/sources.list'
wget --quiet -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y clang-16
- name: Set up Pgrx
run: |
# pg_config
Expand All @@ -92,8 +87,8 @@ jobs:
echo PGRX_TARGET_INFO_PATH_PG$VERSION=$HOME/.pgrx_binding >> "$GITHUB_ENV"
- name: Build
run: |
cargo build --lib --no-default-features --features pg$VERSION --release --target $ARCH-unknown-linux-gnu
./tools/schema.sh --no-default-features --features pg$VERSION --release --target $ARCH-unknown-linux-gnu | expand -t 4 > ./target/pg_bestmatch--$SEMVER.sql
cargo build --lib --features pg$VERSION --release --target $ARCH-unknown-linux-gnu
./tools/schema.sh --features pg$VERSION --release --target $ARCH-unknown-linux-gnu | expand -t 4 > ./target/pg_bestmatch--$SEMVER.sql
- name: Package
run: |
export PLATFORM=$(echo $ARCH | sed 's/aarch64/arm64/; s/x86_64/amd64/')
Expand Down
45 changes: 45 additions & 0 deletions scripts/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -e

printf "SEMVER = ${SEMVER}\n"
printf "VERSION = ${VERSION}\n"
printf "ARCH = ${ARCH}\n"
printf "PLATFORM = ${PLATFORM}\n"

rm -rf ./build/dir_zip
rm -rf ./build/pg_bestmatch-pg${VERSION}_${ARCH}-unknown-linux-gnu_${SEMVER}.zip
rm -rf ./build/dir_deb
rm -rf ./build/pg_bestmatch-pg${VERSION}_${SEMVER}_${PLATFORM}.deb

mkdir -p ./build/dir_zip
cp -a ./sql/upgrade/. ./build/dir_zip/
cp ./target/pg_bestmatch--$SEMVER.sql ./build/dir_zip/pg_bestmatch--$SEMVER.sql
sed -e "s/@CARGO_VERSION@/$SEMVER/g" < ./pg_bestmatch.control > ./build/dir_zip/pg_bestmatch.control
cp ./target/${ARCH}-unknown-linux-gnu/release/libpg_bestmatch.so ./build/dir_zip/pg_bestmatch.so
zip ./build/pg_bestmatch-pg${VERSION}_${ARCH}-unknown-linux-gnu_${SEMVER}.zip -j ./build/dir_zip/*

mkdir -p ./build/dir_deb
mkdir -p ./build/dir_deb/DEBIAN
mkdir -p ./build/dir_deb/usr/share/postgresql/$VERSION/extension/
mkdir -p ./build/dir_deb/usr/lib/postgresql/$VERSION/lib/
for file in $(ls ./build/dir_zip/*.sql | xargs -n 1 basename); do
cp ./build/dir_zip/$file ./build/dir_deb/usr/share/postgresql/$VERSION/extension/$file
done
for file in $(ls ./build/dir_zip/*.control | xargs -n 1 basename); do
cp ./build/dir_zip/$file ./build/dir_deb/usr/share/postgresql/$VERSION/extension/$file
done
for file in $(ls ./build/dir_zip/*.so | xargs -n 1 basename); do
cp ./build/dir_zip/$file ./build/dir_deb/usr/lib/postgresql/$VERSION/lib/$file
done
echo "Package: pg_bestmatch-pg${VERSION}
Version: ${SEMVER}
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://pgvecto.rs/
License: apache2" \
> ./build/dir_deb/DEBIAN/control
(cd ./build/dir_deb && md5sum usr/share/postgresql/$VERSION/extension/* usr/lib/postgresql/$VERSION/lib/*) > ./build/dir_deb/DEBIAN/md5sums
dpkg --build ./build/dir_deb/ ./build/pg_bestmatch-pg${VERSION}_${SEMVER}_${PLATFORM}.deb

0 comments on commit 7758ec6

Please sign in to comment.