1
0
mirror of https://github.com/tensorchord/pgvecto.rs.git synced 2025-08-01 06:46:52 +03:00

ci: bump release version (#186)

* ci: bump release version

[skip ci]

Signed-off-by: usamoi <usamoi@outlook.com>

* ci: bot git name and email

[skip ci]

Signed-off-by: usamoi <usamoi@outlook.com>

---------

Signed-off-by: usamoi <usamoi@outlook.com>
This commit is contained in:
Usamoi
2023-12-16 23:08:23 +08:00
committed by GitHub
parent cc1b7d0f17
commit ebd276e834
3 changed files with 88 additions and 85 deletions

26
.github/workflows/nightly.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Nightly
on:
schedule:
# 00:00 UTC+8 -> 16:00
- cron: "0 16 * * *"
workflow_dispatch:
permissions:
actions: write
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- run: |
commit_date=$(git log -1 --since="24 hours ago" --pretty=format:"%cI")
if [[ -n "$commit_date" ]]; then
TZ='Asia/Shanghai' gh workflow run release.yml \
-f version=$(date +"0.0.0-nightly.%Y%m%d") \
-f prerelease=true
fi
env:
GH_TOKEN: ${{ github.token }}

View File

@ -1,20 +1,17 @@
name: Release name: Release
on: on:
schedule:
# 00:00 UTC+8 -> 16:00
- cron: "0 16 * * *"
workflow_dispatch: workflow_dispatch:
inputs: inputs:
version: version:
type: string type: string
description: The version to be released. description: Version
required: true required: true
prerelease: prerelease:
type: boolean type: boolean
description: Prerelease or not. description: Prerelease
required: true required: true
default: true default: false
permissions: permissions:
contents: write contents: write
@ -26,81 +23,52 @@ env:
RUSTC_WRAPPER: sccache RUSTC_WRAPPER: sccache
jobs: jobs:
setup: release:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- id: check-nightly - uses: actions/github-script@v7
run: |
commit_date=$(git log -1 --since="24 hours ago" --pretty=format:"%cI")
if [[ -n "$commit_date" ]];
then echo "nightly=true" >> $GITHUB_OUTPUT;
else echo "nightly=false" >> $GITHUB_OUTPUT;
fi
- name: Variables
id: variables
uses: actions/github-script@v6
with: with:
script: | script: |
if ("${{ github.event_name }}" == 'schedule') { 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-]+)*))?/;
let date = new Date(); if (!r.test("${{ github.event.inputs.version }}")) {
date.setHours(date.getHours() + 8); core.setFailed(`Action failed with an invalid semver.`);
var yyyy = date.getUTCFullYear();
var mm = String(1 + date.getUTCMonth()).padStart(2, '0');
var dd = String(0 + date.getUTCDate()).padStart(2, '0');
let version = `v0.0.0-nightly.${yyyy}${mm}${dd}`;
core.setOutput('version', version);
if ("${{ steps.check-nightly.outputs.nightly }}" == "true") {
core.setOutput('recheck', 'true');
} else {
core.setOutput('recheck', 'false');
}
core.setOutput('prerelease', true);
} }
if ("${{ github.event_name }}" == 'workflow_dispatch') { - run: |
let version = "${{ github.event.inputs.version }}"; git config --global user.email "support@tensorchord.ai"
let prerelease = "${{ github.event.inputs.prerelease }}"; git config --global user.name "CI[bot]"
core.setOutput('version', version); - run: ./scripts/ci_release.sh
core.setOutput('recheck', 'true'); env:
core.setOutput('prerelease', prerelease); SEMVER: ${{ github.event.inputs.version }}
}
outputs:
version: ${{ steps.variables.outputs.version }}
recheck: ${{ steps.variables.outputs.recheck }}
prerelease: ${{ steps.variables.outputs.prerelease }}
create_github_release:
needs: ["setup"]
if: ${{ needs.setup.outputs.recheck == 'true' }}
runs-on: ubuntu-20.04
steps:
- id: create-release - id: create-release
uses: actions/create-release@v1 uses: actions/create-release@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
tag_name: ${{ needs.setup.outputs.version }} tag_name: v${{ github.event.inputs.version }}
release_name: ${{ needs.setup.outputs.version }} release_name: v${{ github.event.inputs.version }}
draft: false draft: false
prerelease: ${{ needs.setup.outputs.prerelease }} prerelease: ${{ github.event.inputs.prerelease }}
outputs: outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }} upload_url: ${{ steps.create-release.outputs.upload_url }}
upload_github_release: binary:
needs: ["setup", "create_github_release"] needs: ["release"]
if: ${{ needs.setup.outputs.recheck == 'true' }}
strategy: strategy:
matrix: matrix:
include: include:
- { version: 14, arch: amd64, full_arch: x86_64 } - { version: 14, platform: amd64, arch: x86_64 }
- { version: 14, arch: arm64, full_arch: aarch64 } - { version: 14, platform: arm64, arch: aarch64 }
- { version: 15, arch: amd64, full_arch: x86_64 } - { version: 15, platform: amd64, arch: x86_64 }
- { version: 15, arch: arm64, full_arch: aarch64 } - { version: 15, platform: arm64, arch: aarch64 }
- { version: 16, arch: amd64, full_arch: x86_64 } - { version: 16, platform: amd64, arch: x86_64 }
- { version: 16, arch: arm64, full_arch: aarch64 } - { version: 16, platform: arm64, arch: aarch64 }
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
ref: v${{ github.event.inputs.version }}
- uses: actions/cache/restore@v3 - uses: actions/cache/restore@v3
with: with:
path: | path: |
@ -121,17 +89,16 @@ jobs:
sudo apt-get -y install clang-16 sudo apt-get -y install clang-16
cargo install cargo-pgrx --git https://github.com/tensorchord/pgrx.git --rev $(cat Cargo.toml | grep "pgrx =" | awk -F'rev = "' '{print $2}' | cut -d'"' -f1) cargo install cargo-pgrx --git https://github.com/tensorchord/pgrx.git --rev $(cat Cargo.toml | grep "pgrx =" | awk -F'rev = "' '{print $2}' | cut -d'"' -f1)
cargo pgrx init --pg${{ matrix.version }}=/usr/lib/postgresql/${{ matrix.version }}/bin/pg_config cargo pgrx init --pg${{ matrix.version }}=/usr/lib/postgresql/${{ matrix.version }}/bin/pg_config
if [[ "${{ matrix.arch }}" == "arm64" ]]; then if [[ "${{ matrix.arch }}" == "aarch64" ]]; then
sudo apt-get -y install crossbuild-essential-arm64 sudo apt-get -y install crossbuild-essential-arm64
fi fi
- name: Build Release - name: Build Release
id: build_release
run: | run: |
sudo apt-get -y install ruby-dev libarchive-tools sudo apt-get -y install ruby-dev libarchive-tools
sudo gem install --no-document fpm sudo gem install --no-document fpm
mkdir ./artifacts mkdir ./artifacts
cargo pgrx package cargo pgrx package
if [[ "${{ matrix.arch }}" == "arm64" ]]; then if [[ "${{ matrix.arch }}" == "aarch64" ]]; then
cargo build --target aarch64-unknown-linux-gnu --release --features "pg${{ matrix.version }}" --no-default-features cargo build --target aarch64-unknown-linux-gnu --release --features "pg${{ matrix.version }}" --no-default-features
mv ./target/aarch64-unknown-linux-gnu/release/libvectors.so ./target/release/vectors-pg${{ matrix.version }}/usr/lib/postgresql/${{ matrix.version }}/lib/vectors.so mv ./target/aarch64-unknown-linux-gnu/release/libvectors.so ./target/release/vectors-pg${{ matrix.version }}/usr/lib/postgresql/${{ matrix.version }}/lib/vectors.so
fi fi
@ -141,40 +108,40 @@ jobs:
--input-type dir \ --input-type dir \
--output-type deb \ --output-type deb \
--name vectors-pg${{ matrix.version }} \ --name vectors-pg${{ matrix.version }} \
--version ${{ needs.setup.outputs.version }} \ --version ${{ github.event.inputs.version }} \
--license apache2 \ --license apache2 \
--deb-no-default-config-files \ --deb-no-default-config-files \
--package ../vectors-pg${{ matrix.version }}-${{ needs.setup.outputs.version }}-${{ matrix.full_arch }}-unknown-linux-gnu.deb \ --package ../vectors-pg${{ matrix.version }}_${{ github.event.inputs.version }}_${{ matrix.platform }}.deb \
--architecture ${{ matrix.arch }} \ --architecture ${{ matrix.platform }} \
. .
- name: Upload Release / DEB - name: Upload Release
id: upload_release_deb
uses: actions/upload-release-asset@v1 uses: actions/upload-release-asset@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ needs.create_github_release.outputs.upload_url }} upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./vectors-pg${{ matrix.version }}-${{ needs.setup.outputs.version }}-${{ matrix.full_arch }}-unknown-linux-gnu.deb asset_path: ./vectors-pg${{ matrix.version }}_${{ github.event.inputs.version }}_${{ matrix.platform }}.deb
asset_name: vectors-pg${{ matrix.version }}-${{ needs.setup.outputs.version }}-${{ matrix.full_arch }}-unknown-linux-gnu.deb asset_name: vectors-pg${{ matrix.version }}_${{ github.event.inputs.version }}_${{ matrix.platform }}.deb
asset_content_type: application/vnd.debian.binary-package asset_content_type: application/vnd.debian.binary-package
docker_binary_release: docker_binary_release:
needs: ["setup", "create_github_release", "upload_github_release"] needs: ["release", "binary"]
if: ${{ needs.setup.outputs.recheck == 'true' }}
strategy: strategy:
matrix: matrix:
include: include:
- { version: 14, arch: amd64, full_arch: x86_64 } - { version: 14, platform: amd64, arch: x86_64 }
- { version: 14, arch: arm64, full_arch: aarch64 } - { version: 14, platform: arm64, arch: aarch64 }
- { version: 15, arch: amd64, full_arch: x86_64 } - { version: 15, platform: amd64, arch: x86_64 }
- { version: 15, arch: arm64, full_arch: aarch64 } - { version: 15, platform: arm64, arch: aarch64 }
- { version: 16, arch: amd64, full_arch: x86_64 } - { version: 16, platform: amd64, arch: x86_64 }
- { version: 16, arch: arm64, full_arch: aarch64 } - { version: 16, platform: arm64, arch: aarch64 }
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
ref: v${{ github.event.inputs.version }}
- name: Download - name: Download
run: wget -O pgvecto-rs-binary-release.deb https://github.com/tensorchord/pgvecto.rs/releases/download/${{ needs.setup.outputs.version }}/vectors-pg${{ matrix.version }}-${{ needs.setup.outputs.version }}-${{ matrix.full_arch }}-unknown-linux-gnu.deb run: wget -O pgvecto-rs-binary-release.deb https://github.com/tensorchord/pgvecto.rs/releases/download/v${{ github.event.inputs.version }}/vectors-pg${{ matrix.version }}_${{ github.event.inputs.version }}_${{ matrix.platform }}.deb
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx - name: Set up Docker Buildx
@ -189,12 +156,11 @@ jobs:
with: with:
context: . context: .
push: true push: true
platforms: "linux/${{ matrix.arch }}" platforms: "linux/${{ matrix.platform }}"
file: ./docker/binary_release.Dockerfile file: ./docker/binary_release.Dockerfile
tags: tensorchord/pgvecto-rs-binary:pg${{ matrix.version }}-${{ needs.setup.outputs.version }}-${{ matrix.arch }} tags: tensorchord/pgvecto-rs-binary:pg${{ matrix.version }}-${{ github.event.inputs.version }}-${{ matrix.platform }}
docker_release: docker_release:
needs: ["setup", "create_github_release", "upload_github_release", "docker_binary_release"] needs: ["docker_binary_release"]
if: ${{ needs.setup.outputs.recheck == 'true' }}
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
@ -205,13 +171,15 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
ref: v${{ github.event.inputs.version }}
- name: Variables - name: Variables
id: variables id: variables
uses: actions/github-script@v6 uses: actions/github-script@v6
with: with:
script: | script: |
let tags = [ let tags = [
"tensorchord/pgvecto-rs:pg${{ matrix.version }}-${{ needs.setup.outputs.version }}", "tensorchord/pgvecto-rs:pg${{ matrix.version }}-v${{ github.event.inputs.version }}",
"tensorchord/pgvecto-rs:pg${{ matrix.version }}-latest", "tensorchord/pgvecto-rs:pg${{ matrix.version }}-latest",
]; ];
if ("${{ matrix.latest }}" == "true") { if ("${{ matrix.latest }}" == "true") {
@ -235,6 +203,6 @@ jobs:
platforms: "linux/amd64,linux/arm64" platforms: "linux/amd64,linux/arm64"
file: ./docker/pgvecto-rs.Dockerfile file: ./docker/pgvecto-rs.Dockerfile
build-args: | build-args: |
TAG=pg${{ matrix.version }}-${{ needs.setup.outputs.version }} TAG=pg${{ matrix.version }}-v${{ github.event.inputs.version }}
POSTGRES_VERSION=${{ matrix.version }} POSTGRES_VERSION=${{ matrix.version }}
tags: ${{ steps.variables.outputs.tags }} tags: ${{ steps.variables.outputs.tags }}

9
scripts/ci_release.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e
sed -i "s/@CARGO_VERSION@/${SEMVER}/g" ./vectors.control
git add -A
git commit -m "chore: release"
git tag v$SEMVER
git push origin v$SEMVER