From 5fbc9410230007cf5414ad4cd131c5de1832f2dc Mon Sep 17 00:00:00 2001 From: zyy17 Date: Tue, 29 Aug 2023 17:00:45 +0800 Subject: [PATCH] ci: upload the latest artifacts to 'latest/' directory of S3 bucket in scheduled and formal release (#2276) Signed-off-by: zyy17 --- .../actions/build-greptime-binary/action.yml | 5 +++ .../actions/build-linux-artifacts/action.yml | 7 ++++ .github/actions/upload-artifacts/action.yml | 35 +++++++++++++++++-- .github/workflows/nightly-build.yml | 2 ++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/.github/actions/build-greptime-binary/action.yml b/.github/actions/build-greptime-binary/action.yml index f9e47f424f..d03498d789 100644 --- a/.github/actions/build-greptime-binary/action.yml +++ b/.github/actions/build-greptime-binary/action.yml @@ -32,6 +32,10 @@ inputs: description: Upload to S3 required: false default: 'true' + upload-latest-artifacts: + description: Upload the latest artifacts to S3 + required: false + default: 'true' working-dir: description: Working directory to build the artifacts required: false @@ -59,4 +63,5 @@ runs: aws-secret-access-key: ${{ inputs.aws-secret-access-key }} aws-region: ${{ inputs.aws-region }} upload-to-s3: ${{ inputs.upload-to-s3 }} + upload-latest-artifacts: ${{ inputs.upload-latest-artifacts }} working-dir: ${{ inputs.working-dir }} diff --git a/.github/actions/build-linux-artifacts/action.yml b/.github/actions/build-linux-artifacts/action.yml index 381f45126f..003790e412 100644 --- a/.github/actions/build-linux-artifacts/action.yml +++ b/.github/actions/build-linux-artifacts/action.yml @@ -33,6 +33,10 @@ inputs: description: Upload to S3 required: false default: 'true' + upload-latest-artifacts: + description: Upload the latest artifacts to S3 + required: false + default: 'true' working-dir: description: Working directory to build the artifacts required: false @@ -69,6 +73,7 @@ runs: aws-secret-access-key: ${{ inputs.aws-secret-access-key }} aws-region: ${{ inputs.aws-region }} upload-to-s3: ${{ inputs.upload-to-s3 }} + upload-latest-artifacts: ${{ inputs.upload-latest-artifacts }} working-dir: ${{ inputs.working-dir }} - name: Build greptime without pyo3 @@ -85,6 +90,7 @@ runs: aws-secret-access-key: ${{ inputs.aws-secret-access-key }} aws-region: ${{ inputs.aws-region }} upload-to-s3: ${{ inputs.upload-to-s3 }} + upload-latest-artifacts: ${{ inputs.upload-latest-artifacts }} working-dir: ${{ inputs.working-dir }} - name: Clean up the target directory # Clean up the target directory for the centos7 base image, or it will still use the objects of last build. @@ -106,4 +112,5 @@ runs: aws-secret-access-key: ${{ inputs.aws-secret-access-key }} aws-region: ${{ inputs.aws-region }} upload-to-s3: ${{ inputs.upload-to-s3 }} + upload-latest-artifacts: ${{ inputs.upload-latest-artifacts }} working-dir: ${{ inputs.working-dir }} diff --git a/.github/actions/upload-artifacts/action.yml b/.github/actions/upload-artifacts/action.yml index e02a392ba7..3bf622f8e2 100644 --- a/.github/actions/upload-artifacts/action.yml +++ b/.github/actions/upload-artifacts/action.yml @@ -26,6 +26,18 @@ inputs: description: Upload to S3 required: false default: 'true' + upload-latest-artifacts: + description: Upload the latest artifacts to S3 + required: false + default: 'true' + upload-max-retry-times: + description: Max retry times for uploading artifacts to S3 + required: false + default: "20" + upload-retry-timeout: + description: Timeout for uploading artifacts to S3 + required: false + default: "10" # minutes working-dir: description: Working directory to upload the artifacts required: false @@ -74,8 +86,8 @@ runs: AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-secret-access-key }} AWS_DEFAULT_REGION: ${{ inputs.aws-region }} with: - max_attempts: 20 - timeout_minutes: 5 + max_attempts: ${{ inputs.upload-max-retry-times }} + timeout_minutes: ${{ inputs.upload-retry-timeout }} # The bucket layout will be: # releases/greptimedb # ├── v0.1.0 @@ -92,3 +104,22 @@ runs: aws s3 cp \ ${{ inputs.artifacts-dir }}.sha256sum \ s3://${{ inputs.release-to-s3-bucket }}/releases/greptimedb/${{ inputs.version }}/${{ inputs.artifacts-dir }}.sha256sum + + - name: Upload latest artifacts to S3 + if: ${{ inputs.upload-to-s3 == 'true' && inputs.upload-latest-artifacts == 'true' }} # We'll also upload the latest artifacts to S3 in the scheduled and formal release. + uses: nick-invision/retry@v2 + env: + AWS_ACCESS_KEY_ID: ${{ inputs.aws-access-key-id }} + AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-secret-access-key }} + AWS_DEFAULT_REGION: ${{ inputs.aws-region }} + with: + max_attempts: ${{ inputs.upload-max-retry-times }} + timeout_minutes: ${{ inputs.upload-retry-timeout }} + command: | + cd ${{ inputs.working-dir }} && \ + aws s3 cp \ + ${{ inputs.artifacts-dir }}.tar.gz \ + s3://${{ inputs.release-to-s3-bucket }}/releases/greptimedb/latest/${{ inputs.artifacts-dir }}.tar.gz && \ + aws s3 cp \ + ${{ inputs.artifacts-dir }}.sha256sum \ + s3://${{ inputs.release-to-s3-bucket }}/releases/greptimedb/latest/${{ inputs.artifacts-dir }}.sha256sum diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml index d776e6c52d..1373ab7833 100644 --- a/.github/workflows/nightly-build.yml +++ b/.github/workflows/nightly-build.yml @@ -151,6 +151,7 @@ jobs: 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 }} + upload-latest-artifacts: false build-linux-arm64-artifacts: name: Build linux-arm64 artifacts @@ -174,6 +175,7 @@ jobs: 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 }} + upload-latest-artifacts: false release-images-to-dockerhub: name: Build and push images to DockerHub