Skip to content

Commit 5162e08

Browse files
committed
feat: upload download.sh to s3 and auto release
Signed-off-by: Bird <[email protected]>
1 parent 37830ba commit 5162e08

File tree

7 files changed

+60
-10
lines changed

7 files changed

+60
-10
lines changed

.github/workflows/automated-release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ jobs:
7777
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
7878
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
7979
aws-region: ap-southeast-1
80+
- name: update dtm version on s3
81+
run: ./hack/release/update_dtm_version_on_s3.sh ${{ env.TAG }}
8082
- name: upload dtm core to github release and s3
8183
run: bash -e ./hack/release/upload_dtm_core.sh ${{ secrets.GITHUB_TOKEN }} ${{ env.TAG }} ${{ env.GOOS }} ${{ env.GOARCH }}
8284
- name: upload plugins to s3
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: update download.sh
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- hack/install.sh
8+
workflow_dispatch:
9+
10+
jobs:
11+
update-download-script:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Configure AWS credentials
17+
uses: aws-actions/configure-aws-credentials@v1
18+
with:
19+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
20+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
21+
aws-region: ap-southeast-1
22+
- name: Update download.sh
23+
run: aws s3 cp hack/install/download.sh s3://download.devstream.io/download.sh --acl public-read

hack/install/download.sh

100644100755
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
function init() {
4+
# todo customize dtm version, default is latest
45
if [ "$(uname)" == "Darwin" ];then
56
HOST_OS="darwin"
67
elif [ "$(uname)" == "Linux" ];then
@@ -23,23 +24,24 @@ function init() {
2324
}
2425

2526
function getLatestReleaseVersion() {
26-
if [ -n "${GITHUB_TOKEN}" ]; then
27-
AUTH_HEADER="-H Authorization: token ${GITHUB_TOKEN}"
28-
fi
27+
# get latest release version from aws s3
28+
STORAGE_BASE_URL=https://download.devstream.io
29+
LATEST_VERSION_FILE="latest_version"
30+
31+
LATEST_VERSION=$(curl -fsSL ${STORAGE_BASE_URL}/${LATEST_VERSION_FILE})
2932

30-
# like "v1.2.3"
31-
latestVersion=$(curl ${AUTH_HEADER} -s https://api.github.com/repos/devstream-io/devstream/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
32-
if [ -z "$latestVersion" ]; then
33+
if [ -z "${LATEST_VERSION}" ];then
3334
echo "Failed to get latest release version"
3435
exit 1
3536
fi
36-
echo "Latest dtm release version: ${latestVersion}"
37+
38+
echo "Got latest release version: ${LATEST_VERSION}"
3739
}
3840

3941
function downloadDtm() {
4042
# 1. download the release and rename it to "dtm"
4143
# 2. count the download count of the release
42-
fullReleaseUrl="https://devstream.gateway.scarf.sh/releases/$latestVersion/dtm-$HOST_OS-$HOST_ARCH"
44+
fullReleaseUrl="${STORAGE_BASE_URL}/${LATEST_VERSION}/dtm-${HOST_OS}-${HOST_ARCH}"
4345
echo "Downloading dtm from: $fullReleaseUrl"
4446
# use -L to follow redirects
4547
curl -L -o dtm $fullReleaseUrl

hack/release/auto-release-darwin-arm64.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ echo "Uploading ${DTM_CORE_BINARY} ..."
6363
# upload dtm to github release
6464
github-release upload --security-token $github_token --user $user --repo $repo --tag $tag --file dtm --name ${DTM_CORE_BINARY}
6565
# upload dtm to aws s3
66-
aws s3 cp dtm ${STORAGE_URL_WITH_TAG}/${DTM_CORE_BINARY}
66+
aws s3 cp dtm ${STORAGE_URL_WITH_TAG}/${DTM_CORE_BINARY} --acl public-read
6767
echo "${DTM_CORE_BINARY} uploaded."
6868

6969
# upload plugins and .md5 files

hack/release/update_download_sh.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#! /bin/bash -e
2+
3+
DOWNLOAD_SCRIPT_PATH="hack/install/download.sh"
4+
STORAGE_BASE_URL=s3://download.devstream.io
5+
DOWNLOAD_SCRIPT_S3_URL=${STORAGE_BASE_URL}/${DOWNLOAD_SCRIPT_PATH}
6+
7+
# upload download.sh to aws s3
8+
echo "Uploading ${DOWNLOAD_SCRIPT_PATH} to ${DOWNLOAD_SCRIPT_S3_URL} ..."
9+
aws s3 cp ${DOWNLOAD_SCRIPT_PATH} ${DOWNLOAD_SCRIPT_S3_URL} --acl public-read
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#! /bin/bash -e
2+
3+
version=$1
4+
5+
LATEST_VERSION_FILE="latest_version"
6+
STORAGE_BASE_URL=s3://download.devstream.io
7+
8+
# create latest_version file
9+
echo "Saving latest version(${version}) to ${LATEST_VERSION_FILE} ..."
10+
echo $version > ${LATEST_VERSION_FILE}
11+
12+
# create or update latest_version.txt on s3
13+
aws s3 cp ${LATEST_VERSION_FILE} ${STORAGE_BASE_URL}/${LATEST_VERSION_FILE} --acl public-read
14+
echo "${LATEST_VERSION_FILE} uploaded."

hack/release/upload_dtm_core.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ echo "Uploading ${DTM_CORE_BINARY} ..."
1818
# upload dtm to github release
1919
github-release upload --security-token $github_token --user $user --repo $repo --tag $tag --file dtm --name ${DTM_CORE_BINARY}
2020
# upload dtm to aws s3
21-
aws s3 cp dtm ${STORAGE_URL_WITH_TAG}/${DTM_CORE_BINARY}
21+
aws s3 cp dtm ${STORAGE_URL_WITH_TAG}/${DTM_CORE_BINARY} --acl public-read
2222
echo "${DTM_CORE_BINARY} uploaded."
2323

0 commit comments

Comments
 (0)