diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ba7c612b..5590c6ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,3 +29,15 @@ jobs: binary_name: "hrp" ldflags: "-s -w" extra_files: LICENSE README.md docs/CHANGELOG.md + - name: Setup 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 }} + # - name: Upload to aliyun OSS + # run: | + # ossutil cp -rf cli/scripts/install.sh oss://httprunner/ + # ossutil cp -rf hrp-*.tar.gz hrp-*.zip oss://httprunner/ || true + # - name: Test install.sh + # run: bash -c "$(curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh)" diff --git a/.gitignore b/.gitignore index e5528b08..5d528d38 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ __debug_bin .idea/ __pycache__ .DS_Store +*.bak site/ output/ diff --git a/Makefile b/Makefile index b75eb2cc..98c17985 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,11 @@ test: ## run unit tests @echo "go test -race -v ./..." @go test -race -v ./... +.PHONY: bump +bump: ## bump hrp version + @echo "[info] bump hrp version" + @. cli/scripts/bump_version.sh $(version) + .PHONY: build build: ## build hrp cli tool @echo "[info] build hrp cli tool" diff --git a/README.md b/README.md index 4dcc78d1..b3a17c04 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,10 @@ See [CHANGELOG]. You can install `hrp` with one shell command, which will download the latest version's released binary and install to the current system. ```bash -$ curl -sL https://raw.githubusercontent.com/httprunner/hrp/main/cli/scripts/install.sh | bash +# install via curl +$ bash -c "$(curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh)" +# install via wget +$ 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/hrp/cmd/root.go b/cli/hrp/cmd/root.go index 916e6db8..fbb9a633 100644 --- a/cli/hrp/cmd/root.go +++ b/cli/hrp/cmd/root.go @@ -2,6 +2,7 @@ package cmd import ( "os" + "runtime" "strings" "github.com/rs/zerolog" @@ -31,8 +32,12 @@ Website: https://httprunner.com Github: https://github.com/httprunner/hrp Copyright 2021 debugtalk`, PersistentPreRun: func(cmd *cobra.Command, args []string) { + var noColor = false + if runtime.GOOS == "windows" { + noColor = true + } if !logJSON { - log.Logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}).With().Timestamp().Logger() + log.Logger = zerolog.New(zerolog.ConsoleWriter{NoColor: noColor, Out: os.Stderr}).With().Timestamp().Logger() log.Info().Msg("Set log to color console other than JSON format.") } }, diff --git a/cli/scripts/bump_version.sh b/cli/scripts/bump_version.sh new file mode 100644 index 00000000..7be0a2b6 --- /dev/null +++ b/cli/scripts/bump_version.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# build hrp cli binary for testing +# release will be triggered on github actions, see .github/workflows/release.yml + +# Usage: +# $ make bump version=v0.5.2 +# or +# $ bash cli/scripts/bump_version.sh v0.5.2 + +set -e + +version=$1 + +if [ -z "$version" ]; then + echo "version is required" + exit 1 +fi + +echo "bump hrp version to $version" +sed -i'.bak' "s/\"v.*\"/\"$version\"/g" internal/version/init.go + +echo "bump install.sh version to $version" +sed -i'.bak' "s/LATEST_VERSION=\"v.*\"/LATEST_VERSION=\"$version\"/g" cli/scripts/install.sh diff --git a/cli/scripts/install.sh b/cli/scripts/install.sh index b76f0adc..b236a689 100644 --- a/cli/scripts/install.sh +++ b/cli/scripts/install.sh @@ -1,6 +1,8 @@ #!/bin/bash # install hrp with one shell command -# curl -sL https://raw.githubusercontent.com/httprunner/hrp/main/cli/scripts/install.sh | bash +# bash -c "$(curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh)" + +LATEST_VERSION="v0.5.2" set -e @@ -24,6 +26,11 @@ function get_latest_version() { curl -sL https://github.com/httprunner/hrp/releases/latest | grep '