Release #467
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- "v*" | |
schedule: | |
# Release at 00:00 UTC+8 | |
- cron: '0 16 * * *' | |
workflow_dispatch: | |
inputs: | |
tags: | |
description: The tags to be released | |
required: false | |
type: string | |
permissions: | |
id-token: write | |
contents: write | |
jobs: | |
create_release: | |
name: create release | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.generated-tag.outputs.tag }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get latest tag | |
id: get-latest-tag | |
run: | | |
echo "::set-output name=tag::`gh release list -L 1 | cut -f 1`" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Bump version | |
id: generated-tag | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
if (context.ref.startsWith("refs/tags/")) { | |
let tag = context.ref.replace("refs/tags/", ""); | |
core.setOutput('tag', tag); | |
console.log(`This event pushed a tag ${tag}, return directly.`) | |
return | |
} | |
if ("${{ github.event.inputs.tags }}") { | |
let tag = "${{ github.event.inputs.tags }}"; | |
core.setOutput('tag', tag); | |
console.log(`This event triggered by workflow_dispatch with a tag ${tag}, return directly.`) | |
return | |
} | |
let tag = "${{ steps.get-latest-tag.outputs.tag }}"; | |
let result = /v(\d+)\.(\d+)\.(\d+)/g.exec(tag); | |
if (result === null) { | |
throw `The previous tag ${{ steps.get-latest-tag.outputs.tag }} is invalid, ignoring`; | |
} | |
let major = result[1]; | |
let minor = result[2]; | |
let patch = (parseInt(result[3]) + 1).toString(); | |
let next_tag = `v${major}.${minor}.${patch}-nightly`; | |
console.log(`This event is triggered, return generated ${next_tag}.`) | |
core.setOutput('tag', next_tag) | |
- name: Create github release if not exist | |
# Allow this action failure | |
continue-on-error: true | |
# Reference: https://cli.github.com/manual/gh_release_create | |
run: | | |
echo "Create a release for ${{ steps.generated-tag.outputs.tag }}" | |
gh release create ${{ steps.generated-tag.outputs.tag }} --generate-notes -p | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish_macos: | |
name: macos assets | |
runs-on: macos-11 | |
needs: [create_release] | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: | |
- x86_64 | |
- aarch64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get target | |
id: target | |
run: echo ::set-output name=target::${{ matrix.arch }}-apple-darwin | |
- name: Rust setup | |
run: | | |
bash ./scripts/setup/dev_setup.sh -yb | |
- name: Cross setup | |
if: matrix.arch == 'aarch64' | |
run: | | |
rustup target add aarch64-apple-darwin | |
echo "JEMALLOC_SYS_WITH_LG_PAGE=14" >> $GITHUB_ENV | |
- name: Build Binary | |
run: | | |
cargo build --release --target=${{ steps.target.outputs.target }} | |
- name: Pack binaries | |
run: | | |
brew install gnu-tar | |
sudo /usr/sbin/purge | |
mkdir -p release/${{ steps.target.outputs.target }}/{bin,configs} | |
cp ./target/${{ steps.target.outputs.target }}/release/databend-* release/${{ steps.target.outputs.target }}/bin/ | |
rm -f release/${{ steps.target.outputs.target }}/bin/*.d | |
cp ./scripts/ci/deploy/config/databend-query-node-1.toml release/${{ steps.target.outputs.target }}/configs/databend-query.toml | |
cp ./scripts/ci/deploy/config/databend-meta-node-1.toml release/${{ steps.target.outputs.target }}/configs/databend-meta.toml | |
cp ./.github/actions/publish_binary/databend-release-readme.txt release/${{ steps.target.outputs.target }}/readme.txt | |
cp -r ./.github/actions/publish_binary/databend-scripts-for-release release/${{ steps.target.outputs.target }}/scripts | |
gtar -C ./release/${{ steps.target.outputs.target }} -czvf databend-${{ needs.create_release.outputs.version }}-${{ steps.target.outputs.target }}.tar.gz bin configs scripts readme.txt | |
- name: Publish Binaries | |
uses: ./.github/actions/publish_binary | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
version: ${{ needs.create_release.outputs.version }} | |
target: ${{ steps.target.outputs.target }} | |
aws_access_key_id: ${{ secrets.REPO_ACCESS_KEY_ID }} | |
aws_secret_access_key: ${{ secrets.REPO_SECRET_ACCESS_KEY }} | |
publish_linux: | |
name: linux assets | |
runs-on: ubuntu-latest | |
needs: [create_release] | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: | |
- x86_64 | |
- aarch64 | |
platform: | |
- gnu | |
- musl | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get the version | |
id: get_version | |
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | |
- name: Get target | |
id: target | |
run: echo ::set-output name=target::${{ matrix.arch }}-unknown-linux-${{ matrix.platform }} | |
- name: Setup Build Tool | |
uses: ./.github/actions/setup_build_tool | |
with: | |
image: ${{ steps.target.outputs.target }} | |
- name: Set musl rustflags | |
if: matrix.platform == 'musl' | |
run: | | |
flags="-C link-arg=-Wl,--compress-debug-sections=zlib-gabi" | |
echo "RUSTFLAGS=${flags}" >> $GITHUB_ENV | |
- name: Build Binary | |
run: | | |
cargo build --release --target=${{ steps.target.outputs.target }} | |
- name: Copyobj zlib for gnu binaries | |
if: matrix.platform == 'gnu' | |
run: | | |
build-tool /usr/bin/${{ matrix.arch }}-linux-gnu-objcopy --compress-debug-sections=zlib-gnu ./target/${{ steps.target.outputs.target }}/release/databend-query | |
build-tool /usr/bin/${{ matrix.arch }}-linux-gnu-objcopy --compress-debug-sections=zlib-gnu ./target/${{ steps.target.outputs.target }}/release/databend-meta | |
build-tool /usr/bin/${{ matrix.arch }}-linux-gnu-objcopy --compress-debug-sections=zlib-gnu ./target/${{ steps.target.outputs.target }}/release/databend-metactl | |
- name: Pack binaries | |
run: | | |
mkdir -p release/${{ steps.target.outputs.target }}/{bin,configs} | |
cp ./target/${{ steps.target.outputs.target }}/release/databend-* release/${{ steps.target.outputs.target }}/bin/ | |
rm -f release/${{ steps.target.outputs.target }}/bin/*.d | |
cp ./scripts/ci/deploy/config/databend-query-node-1.toml release/${{ steps.target.outputs.target }}/configs/databend-query.toml | |
cp ./scripts/ci/deploy/config/databend-meta-node-1.toml release/${{ steps.target.outputs.target }}/configs/databend-meta.toml | |
cp ./.github/actions/publish_binary/databend-release-readme.txt release/${{ steps.target.outputs.target }}/readme.txt | |
cp -r ./.github/actions/publish_binary/databend-scripts-for-release release/${{ steps.target.outputs.target }}/scripts | |
tar -C ./release/${{ steps.target.outputs.target }} -czvf databend-${{ needs.create_release.outputs.version }}-${{ steps.target.outputs.target }}.tar.gz bin configs scripts readme.txt | |
- name: Publish Binaries | |
uses: ./.github/actions/publish_binary | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
version: ${{ needs.create_release.outputs.version }} | |
target: ${{ steps.target.outputs.target }} | |
aws_access_key_id: ${{ secrets.REPO_ACCESS_KEY_ID }} | |
aws_secret_access_key: ${{ secrets.REPO_SECRET_ACCESS_KEY }} | |
release_docker_combined: | |
name: docker image combined | |
runs-on: ubuntu-latest | |
needs: [create_release, publish_linux] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get the version | |
id: get_version | |
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- uses: ./.github/actions/setup_docker | |
id: login | |
with: | |
repo: databend | |
ecr_role_arn: ${{ secrets.ECR_ROLE_ARN }} | |
dockerhub_user: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Download binaries for usage | |
id: download_binaries | |
run: | | |
mkdir -p ./target/release | |
wget -q https://repo.databend.rs/databend/${{ needs.create_release.outputs.version }}/databend-${{ needs.create_release.outputs.version }}-x86_64-unknown-linux-gnu.tar.gz | |
tar x -C ./target/release -f ./databend-${{ needs.create_release.outputs.version }}-x86_64-unknown-linux-gnu.tar.gz --strip-components 1 bin/ | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
tags: | | |
${{ steps.login.outputs.dockerhub_repo }}:latest | |
${{ steps.login.outputs.dockerhub_repo }}:${{ needs.create_release.outputs.version }} | |
${{ steps.login.outputs.ecr_repo }}:latest | |
${{ steps.login.outputs.ecr_repo }}:${{ needs.create_release.outputs.version }} | |
platforms: linux/amd64 | |
context: . | |
file: ./docker/Dockerfile | |
build-args: VERSION=${{ needs.create_release.outputs.version }} | |
release_docker_separate: | |
name: docker image seperated | |
runs-on: ubuntu-latest | |
needs: [create_release, publish_linux] | |
strategy: | |
fail-fast: false | |
matrix: | |
service: | |
- meta | |
- query | |
distro: | |
- debian | |
- distroless | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get the version | |
id: get_version | |
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- uses: ./.github/actions/setup_docker | |
id: login | |
with: | |
repo: databend-${{ matrix.service }} | |
ecr_role_arn: ${{ secrets.ECR_ROLE_ARN }} | |
dockerhub_user: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Download binaries for usage | |
id: download_binaries | |
run: | | |
version="${{ needs.create_release.outputs.version }}" | |
declare -A platform_targets=( ["arm64"]="aarch64-unknown-linux-gnu" ["amd64"]="x86_64-unknown-linux-gnu") | |
mkdir -p ./distro/ | |
for platform in ${!platform_targets[@]}; do | |
target=${platform_targets[$platform]} | |
wget -P distro -qc https://repo.databend.rs/databend/${version}/databend-${version}-${target}.tar.gz | |
mkdir -p ./target/${target}/release | |
tar x -C ./target/${target}/release -f ./distro/databend-${version}-${target}.tar.gz --strip-components 1 bin/ | |
mkdir -p ./distro/linux/${platform} | |
cp ./target/${target}/release/databend-${{ matrix.service }} ./distro/linux/${platform} | |
done | |
- name: get image tags | |
id: get_image_tags | |
shell: bash | |
run: | | |
dockerhub_base=${{ steps.login.outputs.dockerhub_repo }}:${{ needs.create_release.outputs.version }} | |
ecr_base=${{ steps.login.outputs.ecr_repo }}:${{ needs.create_release.outputs.version }} | |
_tags="${dockerhub_base}-${{ matrix.distro }},${ecr_base}-${{ matrix.distro }}" | |
if [[ "${{ matrix.distro }}" == "debian" ]]; then | |
_tags="${_tags},${dockerhub_base},${ecr_base}" | |
fi | |
echo ::set-output name=IMAGE_TAGS::${_tags} | |
- name: push service image | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
tags: ${{ steps.get_image_tags.outputs.IMAGE_TAGS }} | |
platforms: linux/amd64,linux/arm64 | |
context: . | |
file: ./docker/${{ matrix.distro }}/${{ matrix.service }}.Dockerfile | |
build-args: VERSION=${{ needs.create_release.outputs.version }} | |
release_logic_test_docker_image: | |
name: release logic test docker image | |
runs-on: ubuntu-latest | |
needs: [create_release] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup_docker | |
id: login | |
with: | |
repo: sqllogictest | |
ecr_role_arn: ${{ secrets.ECR_ROLE_ARN }} | |
dockerhub_user: ${{ secrets.DOCKERHUB_USERNAME }} | |
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
tags: | | |
${{ steps.login.outputs.dockerhub_repo }}:latest | |
${{ steps.login.outputs.dockerhub_repo }}:${{ needs.create_release.outputs.version }} | |
${{ steps.login.outputs.ecr_repo }}:latest | |
${{ steps.login.outputs.ecr_repo }}:${{ needs.create_release.outputs.version }} | |
platforms: linux/amd64 | |
context: ./tests/logictest/ | |
file: ./tests/logictest/Dockerfile | |
build-args: VERSION=${{ needs.create_release.outputs.version }} |