From c438c955fb0ee7935c040f4ff73404ab0ee76aa9 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Mon, 25 Apr 2022 16:23:38 +0800 Subject: [PATCH] refactor: get hrp version from aliyun OSS file --- .github/workflows/hrp-release.yml | 3 ++- README.en.md | 2 -- README.md | 2 -- docs/CHANGELOG.md | 1 + hrp/internal/version/VERSION | 1 + hrp/internal/version/init.go | 7 ++++++- httprunner/__init__.py | 2 +- pyproject.toml | 2 +- scripts/bump_version.sh | 9 +++++---- scripts/install.sh | 15 +++++++++------ 10 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 hrp/internal/version/VERSION diff --git a/.github/workflows/hrp-release.yml b/.github/workflows/hrp-release.yml index 4dbb86bc..1821ccbc 100644 --- a/.github/workflows/hrp-release.yml +++ b/.github/workflows/hrp-release.yml @@ -42,7 +42,8 @@ jobs: access-key-secret: ${{ secrets.ALIYUN_ACCESSKEY_SECRET }} - name: Upload artifacts to aliyun OSS run: | + ossutil cp -rf hrp/internal/version/VERSION oss://httprunner/ ossutil cp -rf scripts/install.sh oss://httprunner/ ossutil cp -rf ${{ env.ASSET_PATH }} oss://httprunner/ - name: Test install.sh - run: bash -c "$(curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh)" + run: bash -c "$(curl -ksSL https://httprunner.com/script/install.sh)" diff --git a/README.en.md b/README.en.md index 511a02cd..d1a564e0 100644 --- a/README.en.md +++ b/README.en.md @@ -60,8 +60,6 @@ You can install HttpRunner via one curl command. ```bash $ bash -c "$(curl -ksSL https://httprunner.com/script/install.sh)" -# backup -$ bash -c "$(curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh)" ``` Then you will get a `hrp` CLI tool. diff --git a/README.md b/README.md index b701e953..5d7c2632 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,6 @@ HttpRunner 二进制命令行工具已上传至阿里云 OSS,在系统终端 ```bash $ bash -c "$(curl -ksSL https://httprunner.com/script/install.sh)" -# backup -$ bash -c "$(curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh)" ``` 安装成功后,你将获得一个 `hrp` 命令行工具,执行 `hrp -h` 即可查看到参数帮助说明。 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 54067d1d..4d026a8a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,7 @@ - feat: add builtin function `environ`/`ENV` - fix: demo function compatibility +- change: get hrp version from aliyun OSS file when installing ## v4.0.0-beta (2022-04-24) diff --git a/hrp/internal/version/VERSION b/hrp/internal/version/VERSION new file mode 100644 index 00000000..46390341 --- /dev/null +++ b/hrp/internal/version/VERSION @@ -0,0 +1 @@ +v4.0.0-beta \ No newline at end of file diff --git a/hrp/internal/version/init.go b/hrp/internal/version/init.go index ca433250..4887463b 100644 --- a/hrp/internal/version/init.go +++ b/hrp/internal/version/init.go @@ -1,3 +1,8 @@ package version -const VERSION = "v4.0.0-beta" +import ( + _ "embed" +) + +//go:embed VERSION +var VERSION string diff --git a/httprunner/__init__.py b/httprunner/__init__.py index 1329604f..cbc40932 100644 --- a/httprunner/__init__.py +++ b/httprunner/__init__.py @@ -1,4 +1,4 @@ -__version__ = "4.0.0-beta" +__version__ = "v4.0.0-beta" __description__ = "One-stop solution for HTTP(S) testing." from httprunner.config import Config diff --git a/pyproject.toml b/pyproject.toml index 9c098cf6..c50b5036 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "httprunner" -version = "4.0.0-beta" +version = "v4.0.0-beta" description = "One-stop solution for HTTP(S) testing." license = "Apache-2.0" readme = "README.md" diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index 84e730f6..1abba52d 100644 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -16,11 +16,12 @@ if [ -z "$version" ]; then exit 1 fi -echo "bump hrp version to $version" -sed -i'.bak' "s/\".*\"/\"v$version\"/g" hrp/internal/version/init.go +if [[ $version != v* ]]; then + version="v$version" +fi -echo "bump install.sh version to $version" -sed -i'.bak' "s/LATEST_VERSION=\".*\"/LATEST_VERSION=\"v$version\"/g" scripts/install.sh +echo "bump hrp version to $version" +echo -n "$version" > hrp/internal/version/VERSION echo "bump httprunner version to $version" sed -i'.bak' "s/__version__ = \".*\"/__version__ = \"$version\"/g" httprunner/__init__.py diff --git a/scripts/install.sh b/scripts/install.sh index dfc11491..c16f1c05 100644 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,8 +1,6 @@ #!/bin/bash # install hrp with one shell command -# bash -c "$(curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh)" - -LATEST_VERSION="v4.0.0-beta" +# bash -c "$(curl -ksSL https://httprunner.com/script/install.sh)" set -e @@ -22,8 +20,7 @@ function echoWarn() { export -f echoError function get_latest_version() { - # Release v0.4.0 · httprunner/hrp · GitHub - curl -sL https://github.com/httprunner/httprunner/releases/latest | grep 'Release' | cut -d" " -f4 + curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/VERSION } function get_os() { @@ -61,7 +58,13 @@ function extract_pkg() { function main() { echoInfo "Detect target hrp package..." - version=$LATEST_VERSION + version=$(get_latest_version) + if [[ $version != v* ]]; then + echo "get hrp latest version failed:" + echo "$version" + exit 1 + fi + os=$(get_os) echo "Current OS: $os" arch=$(get_arch)