From adcfdf1922661970742425500f78e50e2f088e9a Mon Sep 17 00:00:00 2001 From: zyy17 Date: Wed, 2 Aug 2023 21:05:25 +0800 Subject: [PATCH] ci: release greptime charts to s3 --- .github/scripts/release-charts-to-s3.sh | 51 +++++++++++++++++++++++++ .github/workflows/release.yaml | 12 ++++++ 2 files changed, 63 insertions(+) create mode 100755 .github/scripts/release-charts-to-s3.sh diff --git a/.github/scripts/release-charts-to-s3.sh b/.github/scripts/release-charts-to-s3.sh new file mode 100755 index 0000000..b73b0ee --- /dev/null +++ b/.github/scripts/release-charts-to-s3.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -ue + +GREPTIME_RELEASE_BUCKET=$1 +RELEASE_DIR=charts + +function update_greptime_charts() { + helm repo add greptime https://greptimeteam.github.io/helm-charts/ + helm repo update +} + +function release_charts_to_s3() { + repo=$1 + chart=$2 + + mkdir "$chart" + echo "Pulling chart from '$repo/$chart'..." + + if [ "$repo" = "greptime" ]; then + # Add '-l devel' to pull the latest development version of greptime. + helm pull "$repo"/"$chart" -d "$chart" --devel + else + helm pull "$repo"/"$chart" -d "$chart" + fi + + package=$(ls ./"$chart") + + if [ -z "$package" ]; then + echo "No package found from $repo/$chart" + exit 1 + fi + + # Get the version from the package, for example, greptimedb-0.1.1-alpha.12.tgz -> 0.1.1-alpha.12. + version=$(echo "$package" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+[-a-zA-Z0-9.]*' | sed 's/.tgz//') + + if [ -z "$version" ]; then + echo "No version found from $repo/$chart" + exit 1 + fi + + echo "Releasing package '$package' to 's3://$GREPTIME_RELEASE_BUCKET/$RELEASE_DIR/$chart/$version'..." + + aws s3 cp "$chart"/"$package" s3://"$GREPTIME_RELEASE_BUCKET"/"$RELEASE_DIR"/"$chart"/"$version"/"$package" + aws s3 cp "$chart"/"$package" s3://"$GREPTIME_RELEASE_BUCKET"/"$RELEASE_DIR"/"$chart"/latest/"$chart"-latest.tgz +} + +update_greptime_charts +release_charts_to_s3 greptime greptimedb-operator +release_charts_to_s3 greptime greptimedb +release_charts_to_s3 oci://registry-1.docker.io/bitnamicharts etcd diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index be8888c..912c54b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,3 +32,15 @@ jobs: env: CR_SKIP_EXISTING: true CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_CN_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_CN_SECRET_ACCESS_KEY }} + aws-region: ${{ vars.AWS_RELEASE_BUCKET_REGION }} + + - name: Release charts to S3 + shell: bash + run: | + .github/scripts/release-charts-to-s3.sh ${{ vars.AWS_RELEASE_BUCKET }}