Skip to content

Commit 0dfbba0

Browse files
authored
ci: upload artifacts use s3 proxy (#7800)
* ci: upload artifacts use s3 proxy Signed-off-by: liyang <daviderli614@gmail.com> * update echo context Signed-off-by: liyang <daviderli614@gmail.com> --------- Signed-off-by: liyang <daviderli614@gmail.com>
1 parent e215851 commit 0dfbba0

File tree

5 files changed

+44
-47
lines changed

5 files changed

+44
-47
lines changed

.github/actions/release-cn-artifacts/action.yaml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,14 @@ inputs:
3737
description: Whether to push the latest tag of the image
3838
required: false
3939
default: 'true'
40-
aws-cn-s3-bucket:
41-
description: S3 bucket to store released artifacts in CN region
40+
proxy-url:
41+
description: The url of the S3 proxy server
4242
required: true
43-
aws-cn-access-key-id:
44-
description: AWS access key id in CN region
43+
proxy-username:
44+
description: The username of the S3 proxy
4545
required: true
46-
aws-cn-secret-access-key:
47-
description: AWS secret access key in CN region
48-
required: true
49-
aws-cn-region:
50-
description: AWS region in CN
46+
proxy-password:
47+
description: The password of the S3 proxy
5148
required: true
5249
upload-to-s3:
5350
description: Upload to S3
@@ -77,30 +74,21 @@ runs:
7774
with:
7875
path: ${{ inputs.artifacts-dir }}
7976

80-
- name: Install s5cmd
81-
shell: bash
82-
run: |
83-
wget https://github.com/peak/s5cmd/releases/download/v2.3.0/s5cmd_2.3.0_Linux-64bit.tar.gz
84-
tar -xzf s5cmd_2.3.0_Linux-64bit.tar.gz
85-
sudo mv s5cmd /usr/local/bin/
86-
sudo chmod +x /usr/local/bin/s5cmd
87-
8877
- name: Release artifacts to cn region
8978
uses: nick-invision/retry@v2
9079
if: ${{ inputs.upload-to-s3 == 'true' }}
9180
env:
92-
AWS_ACCESS_KEY_ID: ${{ inputs.aws-cn-access-key-id }}
93-
AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-cn-secret-access-key }}
94-
AWS_REGION: ${{ inputs.aws-cn-region }}
81+
PROXY_URL: ${{ inputs.proxy-url }}
82+
PROXY_USERNAME: ${{ inputs.proxy-username }}
83+
PROXY_PASSWORD: ${{ inputs.proxy-password }}
9584
UPDATE_VERSION_INFO: ${{ inputs.update-version-info }}
9685
with:
9786
max_attempts: ${{ inputs.upload-max-retry-times }}
9887
timeout_minutes: ${{ inputs.upload-retry-timeout }}
9988
command: |
10089
./.github/scripts/upload-artifacts-to-s3.sh \
10190
${{ inputs.artifacts-dir }} \
102-
${{ inputs.version }} \
103-
${{ inputs.aws-cn-s3-bucket }}
91+
${{ inputs.version }}
10492
10593
- name: Push greptimedb image from Dockerhub to ACR
10694
shell: bash

.github/scripts/upload-artifacts-to-s3.sh

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@ set -o pipefail
55

66
ARTIFACTS_DIR=$1
77
VERSION=$2
8-
AWS_S3_BUCKET=$3
98
RELEASE_DIRS="releases/greptimedb"
109
GREPTIMEDB_REPO="GreptimeTeam/greptimedb"
1110

1211
# Check if necessary variables are set.
1312
function check_vars() {
14-
for var in AWS_S3_BUCKET VERSION ARTIFACTS_DIR; do
13+
for var in VERSION ARTIFACTS_DIR; do
1514
if [ -z "${!var}" ]; then
1615
echo "$var is not set or empty."
17-
echo "Usage: $0 <artifacts-dir> <version> <aws-s3-bucket>"
16+
echo "Usage: $0 <artifacts-dir> <version>"
1817
exit 1
1918
fi
2019
done
@@ -33,8 +32,13 @@ function upload_artifacts() {
3332
# ├── greptime-darwin-amd64-v0.2.0.sha256sum
3433
# └── greptime-darwin-amd64-v0.2.0.tar.gz
3534
find "$ARTIFACTS_DIR" -type f \( -name "*.tar.gz" -o -name "*.sha256sum" \) | while IFS= read -r file; do
36-
s5cmd cp \
37-
"$file" "s3://$AWS_S3_BUCKET/$RELEASE_DIRS/$VERSION/$(basename "$file")"
35+
filename=$(basename "$file")
36+
TARGET_URL="$PROXY_URL/$RELEASE_DIRS/$VERSION/$filename"
37+
38+
curl -X PUT \
39+
-u "$PROXY_USERNAME:$PROXY_PASSWORD" \
40+
-F "file=@$file" \
41+
"$TARGET_URL"
3842
done
3943
}
4044

@@ -45,16 +49,24 @@ function update_version_info() {
4549
if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
4650
echo "Updating latest-version.txt"
4751
echo "$VERSION" > latest-version.txt
48-
s5cmd cp \
49-
latest-version.txt "s3://$AWS_S3_BUCKET/$RELEASE_DIRS/latest-version.txt"
52+
TARGET_URL="$PROXY_URL/$RELEASE_DIRS/latest-version.txt"
53+
54+
curl -X PUT \
55+
-u "$PROXY_USERNAME:$PROXY_PASSWORD" \
56+
-F "file=@latest-version.txt" \
57+
"$TARGET_URL"
5058
fi
5159

5260
# If it's the nightly release, update latest-nightly-version.txt.
5361
if [[ "$VERSION" == *"nightly"* ]]; then
5462
echo "Updating latest-nightly-version.txt"
5563
echo "$VERSION" > latest-nightly-version.txt
56-
s5cmd cp \
57-
latest-nightly-version.txt "s3://$AWS_S3_BUCKET/$RELEASE_DIRS/latest-nightly-version.txt"
64+
65+
TARGET_URL="$PROXY_URL/$RELEASE_DIRS/latest-nightly-version.txt"
66+
curl -X PUT \
67+
-u "$PROXY_USERNAME:$PROXY_PASSWORD" \
68+
-F "file=@latest-nightly-version.txt" \
69+
"$TARGET_URL"
5870
fi
5971
fi
6072
}
@@ -93,10 +105,10 @@ function main() {
93105
}
94106

95107
# Usage example:
96-
# AWS_ACCESS_KEY_ID=<your_access_key_id> \
97-
# AWS_SECRET_ACCESS_KEY=<your_secret_access_key> \
98-
# AWS_DEFAULT_REGION=<your_region> \
108+
# PROXY_URL=<proxy_url> \
109+
# PROXY_USERNAME=<proxy_username> \
110+
# PROXY_PASSWORD=<proxy_password> \
99111
# UPDATE_VERSION_INFO=true \
100112
# DOWNLOAD_ARTIFACTS_FROM_GITHUB=false \
101-
# ./upload-artifacts-to-s3.sh <artifacts-dir> <version> <aws-s3-bucket>
113+
# ./upload-artifacts-to-s3.sh <artifacts-dir> <version>
102114
main

.github/workflows/dev-build.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,9 @@ jobs:
285285
dst-image-registry: ${{ vars.ACR_IMAGE_REGISTRY }}
286286
dst-image-namespace: ${{ vars.IMAGE_NAMESPACE }}
287287
version: ${{ needs.allocate-runners.outputs.version }}
288-
aws-cn-s3-bucket: ${{ vars.AWS_RELEASE_BUCKET }}
289-
aws-cn-access-key-id: ${{ secrets.AWS_CN_ACCESS_KEY_ID }}
290-
aws-cn-secret-access-key: ${{ secrets.AWS_CN_SECRET_ACCESS_KEY }}
291-
aws-cn-region: ${{ vars.AWS_RELEASE_BUCKET_REGION }}
288+
proxy-url: ${{ secrets.PROXY_URL }}
289+
proxy-username: ${{ secrets.PROXY_USERNAME }}
290+
proxy-password: ${{ secrets.PROXY_PASSWORD }}
292291
upload-to-s3: ${{ inputs.upload_artifacts_to_s3 }}
293292
dev-mode: true # Only build the standard images(exclude centos images).
294293
push-latest-tag: false # Don't push the latest tag to registry.

.github/workflows/nightly-build.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,9 @@ jobs:
236236
dst-image-registry: ${{ vars.ACR_IMAGE_REGISTRY }}
237237
dst-image-namespace: ${{ vars.IMAGE_NAMESPACE }}
238238
version: ${{ needs.allocate-runners.outputs.version }}
239-
aws-cn-s3-bucket: ${{ vars.AWS_RELEASE_BUCKET }}
240-
aws-cn-access-key-id: ${{ secrets.AWS_CN_ACCESS_KEY_ID }}
241-
aws-cn-secret-access-key: ${{ secrets.AWS_CN_SECRET_ACCESS_KEY }}
242-
aws-cn-region: ${{ vars.AWS_RELEASE_BUCKET_REGION }}
239+
proxy-url: ${{ secrets.PROXY_URL }}
240+
proxy-username: ${{ secrets.PROXY_USERNAME }}
241+
proxy-password: ${{ secrets.PROXY_PASSWORD }}
243242
upload-to-s3: false
244243
dev-mode: false
245244
update-version-info: false # Don't update version info in S3.

.github/workflows/release.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,9 @@ jobs:
358358
dst-image-registry: ${{ vars.ACR_IMAGE_REGISTRY }}
359359
dst-image-namespace: ${{ vars.IMAGE_NAMESPACE }}
360360
version: ${{ needs.allocate-runners.outputs.version }}
361-
aws-cn-s3-bucket: ${{ vars.AWS_RELEASE_BUCKET }}
362-
aws-cn-access-key-id: ${{ secrets.AWS_CN_ACCESS_KEY_ID }}
363-
aws-cn-secret-access-key: ${{ secrets.AWS_CN_SECRET_ACCESS_KEY }}
364-
aws-cn-region: ${{ vars.AWS_RELEASE_BUCKET_REGION }}
361+
proxy-url: ${{ secrets.PROXY_URL }}
362+
proxy-username: ${{ secrets.PROXY_USERNAME }}
363+
proxy-password: ${{ secrets.PROXY_PASSWORD }}
365364
dev-mode: false
366365
upload-to-s3: true
367366
update-version-info: true

0 commit comments

Comments
 (0)