diff --git a/.circleci/config.yml b/.circleci/config.yml index 68adeb6c7..7979824ad 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -54,6 +54,19 @@ jobs: echo "Version from kube-linter: ${version}. Expected version: ${expected_version}" [[ "${version}" == "${expected_version}" ]] + - run: + name: Create a GitHub release, if on tag. + command: | + [[ -n "${CIRCLE_TAG}" ]] || exit 0 + + wget --quiet https://github.com/gruntwork-io/fetch/releases/download/v0.3.5/fetch_linux_amd64 + sudo install fetch_linux_amd64 /usr/bin/fetch + ghr_version="v0.13.0" + fetch --repo="https://github.com/tcnksm/ghr" --tag="${ghr_version}" --release-asset="ghr_${ghr_version}_linux_amd64.tar.gz" . + tar -zxvf ghr_${ghr_version}_linux_amd64.tar.gz + sudo install ghr_${ghr_version}_linux_amd64/ghr /usr/bin/ghr + which ghr + ./scripts/create_github_release.sh "${CIRCLE_TAG}" ./bin workflows: version: 2 diff --git a/scripts/create_github_release.sh b/scripts/create_github_release.sh new file mode 100755 index 000000000..ae5ac3964 --- /dev/null +++ b/scripts/create_github_release.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +source "${SCRIPT_DIR}/utils.sh" + +set -eo pipefail + +[[ -n "${GITHUB_TOKEN}" ]] || die "No GITHUB_TOKEN found." + +tag="$1" +bin_dir="$2" +[[ -n "${tag}" && -n "${bin_dir}" ]] || die "Usage: $0 " + +tmp_dir="$(mktemp -d)" +for os in darwin linux windows; do + bin_name="kube-linter" + if [[ "${os}" == "windows" ]]; then + bin_name="kube-linter.exe" + fi + tar -C "${bin_dir}/${os}" -czf "${tmp_dir}/kube-linter-${os}.tar.gz" "${bin_name}" + zip --junk-paths "${tmp_dir}/kube-linter-${os}.zip" "${bin_dir}/${os}/${bin_name}" +done + +ghr -prerelease -n "v${tag}" "${tag}" "${tmp_dir}" +rm -rf "${tmp_dir}"