Skip to content

Commit

Permalink
Upload release artifacts when a tag is cut (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
viswajithiii authored Sep 22, 2020
1 parent 3dd7446 commit e6966fc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions scripts/create_github_release.sh
Original file line number Diff line number Diff line change
@@ -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 <tag> <binary_directory>"

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}"

0 comments on commit e6966fc

Please sign in to comment.