Skip to content

Commit e6966fc

Browse files
authored
Upload release artifacts when a tag is cut (#8)
1 parent 3dd7446 commit e6966fc

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

.circleci/config.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ jobs:
5454
echo "Version from kube-linter: ${version}. Expected version: ${expected_version}"
5555
[[ "${version}" == "${expected_version}" ]]
5656
57+
- run:
58+
name: Create a GitHub release, if on tag.
59+
command: |
60+
[[ -n "${CIRCLE_TAG}" ]] || exit 0
61+
62+
wget --quiet https://github.com/gruntwork-io/fetch/releases/download/v0.3.5/fetch_linux_amd64
63+
sudo install fetch_linux_amd64 /usr/bin/fetch
64+
ghr_version="v0.13.0"
65+
fetch --repo="https://github.com/tcnksm/ghr" --tag="${ghr_version}" --release-asset="ghr_${ghr_version}_linux_amd64.tar.gz" .
66+
tar -zxvf ghr_${ghr_version}_linux_amd64.tar.gz
67+
sudo install ghr_${ghr_version}_linux_amd64/ghr /usr/bin/ghr
68+
which ghr
69+
./scripts/create_github_release.sh "${CIRCLE_TAG}" ./bin
5770
5871
workflows:
5972
version: 2

scripts/create_github_release.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
4+
source "${SCRIPT_DIR}/utils.sh"
5+
6+
set -eo pipefail
7+
8+
[[ -n "${GITHUB_TOKEN}" ]] || die "No GITHUB_TOKEN found."
9+
10+
tag="$1"
11+
bin_dir="$2"
12+
[[ -n "${tag}" && -n "${bin_dir}" ]] || die "Usage: $0 <tag> <binary_directory>"
13+
14+
tmp_dir="$(mktemp -d)"
15+
for os in darwin linux windows; do
16+
bin_name="kube-linter"
17+
if [[ "${os}" == "windows" ]]; then
18+
bin_name="kube-linter.exe"
19+
fi
20+
tar -C "${bin_dir}/${os}" -czf "${tmp_dir}/kube-linter-${os}.tar.gz" "${bin_name}"
21+
zip --junk-paths "${tmp_dir}/kube-linter-${os}.zip" "${bin_dir}/${os}/${bin_name}"
22+
done
23+
24+
ghr -prerelease -n "v${tag}" "${tag}" "${tmp_dir}"
25+
rm -rf "${tmp_dir}"

0 commit comments

Comments
 (0)