Release #87
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
on: | |
push: | |
tags: | |
- "v*.*.*" | |
schedule: | |
# At 00:00 on Monday. | |
- cron: '0 0 * * 1' | |
workflow_dispatch: | |
name: Release | |
env: | |
RUST_TOOLCHAIN: nightly-2022-12-20 | |
# FIXME(zyy17): Would be better to use `gh release list -L 1 | cut -f 3` to get the latest release version tag, but for a long time, we will stay at 'v0.1.0-alpha-*'. | |
SCHEDULED_BUILD_VERSION_PREFIX: v0.1.0-alpha | |
# In the future, we can change SCHEDULED_PERIOD to nightly. | |
SCHEDULED_PERIOD: weekly | |
CARGO_PROFILE: weekly | |
jobs: | |
build: | |
name: Build binary | |
strategy: | |
matrix: | |
# The file format is greptime-<os>-<arch> | |
include: | |
- arch: x86_64-unknown-linux-gnu | |
os: ubuntu-2004-16-cores | |
file: greptime-linux-amd64 | |
- arch: aarch64-unknown-linux-gnu | |
os: ubuntu-2004-16-cores | |
file: greptime-linux-arm64 | |
- arch: aarch64-apple-darwin | |
os: macos-latest | |
file: greptime-darwin-arm64 | |
- arch: x86_64-apple-darwin | |
os: macos-latest | |
file: greptime-darwin-amd64 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Cache cargo assets | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ matrix.arch }}-build-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install Protoc for linux | |
if: contains(matrix.arch, 'linux') && endsWith(matrix.arch, '-gnu') | |
run: | # Make sure the protoc is >= 3.15 | |
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-linux-x86_64.zip | |
unzip protoc-21.9-linux-x86_64.zip -d protoc | |
sudo cp protoc/bin/protoc /usr/local/bin/ | |
sudo cp -r protoc/include/google /usr/local/include/ | |
- name: Install Protoc for macos | |
if: contains(matrix.arch, 'darwin') | |
run: | | |
brew install protobuf | |
- name: Install etcd for linux | |
if: contains(matrix.arch, 'linux') && endsWith(matrix.arch, '-gnu') | |
run: | | |
ETCD_VER=v3.5.7 | |
DOWNLOAD_URL=https://github.com/etcd-io/etcd/releases/download | |
curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz | |
mkdir -p /tmp/etcd-download | |
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download --strip-components=1 | |
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz | |
sudo cp -a /tmp/etcd-download/etcd* /usr/local/bin/ | |
nohup etcd >/tmp/etcd.log 2>&1 & | |
- name: Install etcd for macos | |
if: contains(matrix.arch, 'darwin') | |
run: | | |
brew install etcd | |
brew services start etcd | |
- name: Install dependencies for linux | |
if: contains(matrix.arch, 'linux') && endsWith(matrix.arch, '-gnu') | |
run: | | |
sudo apt-get -y update | |
sudo apt-get -y install libssl-dev pkg-config g++-aarch64-linux-gnu gcc-aarch64-linux-gnu | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.RUST_TOOLCHAIN }} | |
targets: ${{ matrix.arch }} | |
- name: Output package versions | |
run: protoc --version ; cargo version ; rustc --version ; gcc --version ; g++ --version | |
- name: Run tests | |
run: make unit-test integration-test sqlness-test | |
- name: Run cargo build | |
run: cargo build ${{ matrix.opts }} --profile ${{ env.CARGO_PROFILE }} --locked --target ${{ matrix.arch }} | |
- name: Calculate checksum and rename binary | |
shell: bash | |
run: | | |
cd target/${{ matrix.arch }}/${{ env.CARGO_PROFILE }} | |
chmod +x greptime | |
tar -zcvf ${{ matrix.file }}.tgz greptime | |
echo $(shasum -a 256 ${{ matrix.file }}.tgz | cut -f1 -d' ') > ${{ matrix.file }}.sha256sum | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.file }} | |
path: target/${{ matrix.arch }}/${{ env.CARGO_PROFILE }}/${{ matrix.file }}.tgz | |
- name: Upload checksum of artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.file }}.sha256sum | |
path: target/${{ matrix.arch }}/${{ env.CARGO_PROFILE }}/${{ matrix.file }}.sha256sum | |
release: | |
name: Release artifacts | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
- name: Configure scheduled build version # the version would be ${SCHEDULED_BUILD_VERSION_PREFIX}-YYYYMMDD-${SCHEDULED_PERIOD}, like v0.1.0-alpha-20221119-weekly. | |
shell: bash | |
if: github.event_name == 'schedule' | |
run: | | |
buildTime=`date "+%Y%m%d"` | |
SCHEDULED_BUILD_VERSION=${{ env.SCHEDULED_BUILD_VERSION_PREFIX }}-$buildTime-${{ env.SCHEDULED_PERIOD }} | |
echo "SCHEDULED_BUILD_VERSION=${SCHEDULED_BUILD_VERSION}" >> $GITHUB_ENV | |
- name: Create scheduled build git tag | |
if: github.event_name == 'schedule' | |
run: | | |
git tag ${{ env.SCHEDULED_BUILD_VERSION }} | |
- name: Publish scheduled release # configure the different release title and tags. | |
uses: softprops/action-gh-release@v1 | |
if: github.event_name == 'schedule' | |
with: | |
name: "Release ${{ env.SCHEDULED_BUILD_VERSION }}" | |
tag_name: ${{ env.SCHEDULED_BUILD_VERSION }} | |
generate_release_notes: true | |
files: | | |
**/greptime-* | |
- name: Publish release | |
uses: softprops/action-gh-release@v1 | |
if: github.event_name != 'schedule' | |
with: | |
name: "Release ${{ github.ref_name }}" | |
files: | | |
**/greptime-* | |
docker: | |
name: Build docker image | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Download amd64 binary | |
uses: actions/download-artifact@v3 | |
with: | |
name: greptime-linux-amd64 | |
path: amd64 | |
- name: Unzip the amd64 artifacts | |
run: | | |
cd amd64 | |
tar xvf greptime-linux-amd64.tgz | |
rm greptime-linux-amd64.tgz | |
- name: Download arm64 binary | |
uses: actions/download-artifact@v3 | |
with: | |
name: greptime-linux-arm64 | |
path: arm64 | |
- name: Unzip the arm64 artifacts | |
run: | | |
cd arm64 | |
tar xvf greptime-linux-arm64.tgz | |
rm greptime-linux-arm64.tgz | |
- name: Login to UCloud Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: uhub.service.ucloud.cn | |
username: ${{ secrets.UCLOUD_USERNAME }} | |
password: ${{ secrets.UCLOUD_PASSWORD }} | |
- name: Login to Dockerhub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Configure scheduled build image tag # the tag would be ${SCHEDULED_BUILD_VERSION_PREFIX}-YYYYMMDD-${SCHEDULED_PERIOD} | |
shell: bash | |
if: github.event_name == 'schedule' | |
run: | | |
buildTime=`date "+%Y%m%d"` | |
SCHEDULED_BUILD_VERSION=${{ env.SCHEDULED_BUILD_VERSION_PREFIX }}-$buildTime-${{ env.SCHEDULED_PERIOD }} | |
echo "IMAGE_TAG=${SCHEDULED_BUILD_VERSION:1}" >> $GITHUB_ENV | |
- name: Configure tag # If the release tag is v0.1.0, then the image version tag will be 0.1.0. | |
shell: bash | |
if: github.event_name != 'schedule' | |
run: | | |
VERSION=${{ github.ref_name }} | |
echo "IMAGE_TAG=${VERSION:1}" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./docker/ci/Dockerfile | |
push: true | |
platforms: linux/amd64,linux/arm64 | |
tags: | | |
greptime/greptimedb:latest | |
greptime/greptimedb:${{ env.IMAGE_TAG }} | |
uhub.service.ucloud.cn/greptime/greptimedb:latest | |
uhub.service.ucloud.cn/greptime/greptimedb:${{ env.IMAGE_TAG }} |