diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ba7c612b..8e8b2bb7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,3 +29,10 @@ jobs: binary_name: "hrp" ldflags: "-s -w" extra_files: LICENSE README.md docs/CHANGELOG.md + - name: Upload to aliyun OSS + uses: manyuanrong/setup-ossutil@v2.0 + with: + endpoint: "oss-cn-beijing.aliyuncs.com" + access-key-id: ${{ secrets.ALIYUN_ACCESSKEY_ID }} + access-key-secret: ${{ secrets.ALIYUN_ACCESSKEY_SECRET }} + - run: ossutil cp -rf cli/scripts/install.sh *.tar.gz *.zip oss://httprunner/ diff --git a/README.md b/README.md index 509de57b..b3a17c04 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,9 @@ You can install `hrp` with one shell command, which will download the latest ver ```bash # install via curl -$ bash -c "$(curl -ksSL https://raw.githubusercontent.com/httprunner/hrp/main/cli/scripts/install.sh)" +$ bash -c "$(curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh)" # install via wget -$ bash -c "$(wget https://raw.githubusercontent.com/httprunner/hrp/main/cli/scripts/install.sh -O -)" +$ bash -c "$(wget https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh -O -)" ``` If you are a golang developer, you can also install `hrp` with `go get`. diff --git a/cli/scripts/install.sh b/cli/scripts/install.sh index f404b4fa..034eb8dd 100644 --- a/cli/scripts/install.sh +++ b/cli/scripts/install.sh @@ -1,6 +1,6 @@ #!/bin/bash # install hrp with one shell command -# bash -c "$(curl -ksSL https://raw.githubusercontent.com/httprunner/hrp/main/cli/scripts/install.sh)" +# bash -c "$(curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh)" set -e @@ -24,6 +24,11 @@ function get_latest_version() { curl -sL https://github.com/httprunner/hrp/releases/latest | grep 'Release' | cut -d" " -f4 } +function get_os() { + os=$(uname -s) + echo "$os" | tr '[:upper:]' '[:lower:]' +} + function get_arch() { arch=$(uname -m) if [ "$arch" == "x86_64" ]; then @@ -32,16 +37,24 @@ function get_arch() { echo "$arch" } +function get_download_url() { + # github + # url="https://github.com/httprunner/hrp/releases/download/$version/$1" + # aliyun oss + url="https://httprunner.oss-cn-beijing.aliyuncs.com/$1" + echo $url +} + function main() { echoInfo "Detect target hrp package..." version=$(get_latest_version) echo "Latest version: $version" - os=$(uname -s) + os=$(get_os) echo "Current OS: $os" arch=$(get_arch) echo "Current ARCH: $arch" pkg="hrp-$version-$os-$arch.tar.gz" - url="https://github.com/httprunner/hrp/releases/download/$version/$pkg" + url=$(get_download_url $pkg) echo "Selected package: $url" echo