mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-07 13:52:59 +00:00
225 lines
7.2 KiB
YAML
225 lines
7.2 KiB
YAML
on:
|
|
push:
|
|
tags:
|
|
- "v*.*.*"
|
|
schedule:
|
|
# At 00:00 Everyday
|
|
# https://crontab.guru/every-day-at-midnight
|
|
- cron: '0 0 * * *'
|
|
workflow_dispatch:
|
|
|
|
name: Release
|
|
|
|
env:
|
|
RUST_TOOLCHAIN: nightly-2022-07-14
|
|
|
|
# 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-*'.
|
|
NIGHTLY_BUILD_VERSION_PREFIX: v0.1.0-alpha
|
|
|
|
jobs:
|
|
build:
|
|
name: Build binary
|
|
strategy:
|
|
matrix:
|
|
# The file format is greptime-<os>-<arch>
|
|
include:
|
|
- arch: x86_64-unknown-linux-gnu
|
|
os: ubuntu-latest-16-cores
|
|
file: greptime-linux-amd64
|
|
- arch: aarch64-unknown-linux-gnu
|
|
os: ubuntu-latest-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 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 cargo build
|
|
run: cargo build ${{ matrix.opts }} --release --locked --target ${{ matrix.arch }}
|
|
|
|
- name: Calculate checksum and rename binary
|
|
shell: bash
|
|
run: |
|
|
cd target/${{ matrix.arch }}/release
|
|
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 }}/release/${{ matrix.file }}.tgz
|
|
|
|
- name: Upload checksum of artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ matrix.file }}.sha256sum
|
|
path: target/${{ matrix.arch }}/release/${{ 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 nightly build version # the version would be ${NIGHTLY_BUILD_VERSION_PREFIX}-YYYYMMDD-nightly, like v0.1.0-alpha-20221119-nightly.
|
|
shell: bash
|
|
if: github.event_name == 'schedule'
|
|
run: |
|
|
buildTime=`date "+%Y%m%d"`
|
|
NIGHTLY_VERSION=${{ env.NIGHTLY_BUILD_VERSION_PREFIX }}-$buildTime-nightly
|
|
echo "NIGHTLY_VERSION=${NIGHTLY_VERSION}" >> $GITHUB_ENV
|
|
|
|
- name: Create nightly git tag
|
|
if: github.event_name == 'schedule'
|
|
run: |
|
|
git tag ${{ env.NIGHTLY_VERSION }}
|
|
|
|
- name: Publish nightly release # configure the different release title and tags.
|
|
uses: softprops/action-gh-release@v1
|
|
if: github.event_name == 'schedule'
|
|
with:
|
|
name: "Release ${{ env.NIGHTLY_VERSION }}"
|
|
tag_name: ${{ env.NIGHTLY_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 nightly build image tag # the tag would be ${NIGHTLY_BUILD_VERSION_PREFIX}-YYYYMMDD-nightly
|
|
shell: bash
|
|
if: github.event_name == 'schedule'
|
|
run: |
|
|
buildTime=`date "+%Y%m%d"`
|
|
NIGHTLY_VERSION=${{ env.NIGHTLY_BUILD_VERSION_PREFIX }}-$buildTime-nightly
|
|
echo "IMAGE_TAG=${NIGHTLY_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 }}
|