Skip to content

Commit 9dbd4d8

Browse files
authored
Merge pull request #33 from codacy/fix/content-type
Fix/content type
2 parents d21e8db + 9d3dbea commit 9dbd4d8

File tree

4 files changed

+154
-29
lines changed

4 files changed

+154
-29
lines changed

.circleci/config.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
version: 2.1
22

33
orbs:
4-
codacy: codacy/base@2.0.0
4+
codacy: codacy/base@5.0.4
55

66
jobs:
77
build: # runs not using Workflows must have a `build` job as entry point
88
docker: # run the steps with Docker
99
# CircleCI Go images available at: https://hub.docker.com/r/circleci/golang/
1010
- image: circleci/golang:1.15 #
11-
11+
1212
# directory where steps are run. Path must conform to the Go Workspace requirements
1313
working_directory: ~/workdir/helm-ssm
14-
14+
1515
environment: # environment variables for the build itself
1616
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
1717

@@ -38,7 +38,7 @@ jobs:
3838

3939
- persist_to_workspace:
4040
root: ~/workdir/helm-ssm
41-
paths:
41+
paths:
4242
- '*'
4343

4444
- save_cache: # Store cache in the /go/pkg directory
@@ -70,14 +70,13 @@ jobs:
7070
export VERSION="$(cat .version)"
7171
echo "Publishing version ${VERSION}"
7272
ls -lisah ./_dist/
73-
go get github.com/tcnksm/ghr
74-
if [ "${CIRCLE_BRANCH}" == "master" ]; then
75-
export RELEASE_TAG="latest"
76-
else
77-
export RELEASE_TAG="dev"
78-
fi
79-
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} ${VERSION} ./_dist/
80-
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -replace ${RELEASE_TAG} ./_dist/
73+
74+
curl -L https://github.com/cli/cli/releases/download/v1.1.0/gh_1.1.0_linux_amd64.deb -o gh.deb
75+
sudo dpkg -i gh.deb
76+
echo ${GITHUB_TOKEN} | gh auth login --with-token
77+
gh config set prompt disabled
78+
gh release create ${VERSION} ./_dist/*.tgz
79+
8180
8281
workflows:
8382
version: 2
@@ -100,3 +99,10 @@ workflows:
10099
context: CodacyGitHub
101100
requires:
102101
- tag_version
102+
- codacy/tag_version:
103+
name: tag_version_latest
104+
context: CodacyAWS
105+
version: latest
106+
force: true
107+
requires:
108+
- publish

README.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,8 @@ $ helm ssm [flags]
7878
Choose the latest version from the releases and install the
7979
appropriate version for your OS as indicated below.
8080

81-
### Linux
82-
83-
```sh
84-
$ helm plugin install https://github.com/codacy/helm-ssm/releases/download/latest/helm-ssm-linux.tgz
85-
```
86-
87-
### MacOS
88-
89-
```sh
90-
$ helm plugin install https://github.com/codacy/helm-ssm/releases/download/latest/helm-ssm-macos.tgz
91-
```
92-
93-
### Windows
94-
9581
```sh
96-
$ helm plugin install https://github.com/codacy/helm-ssm/releases/download/latest/helm-ssm-windows.tgz
82+
$ helm plugin add https://github.com/codacy/helm-ssm
9783
```
9884

9985
### Developer (From Source) Install

install-binary.sh

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#!/usr/bin/env bash
2+
3+
# Copied from https://github.com/technosophos/helm-template
4+
# Combination of the Glide and Helm scripts, with my own tweaks.
5+
6+
PROJECT_NAME="helm-ssm"
7+
PROJECT_GH="codacy/$PROJECT_NAME"
8+
$(helm env)
9+
10+
# Convert the HELM_PLUGIN to unix if cygpath is
11+
# available. This is the case when using MSYS2 or Cygwin
12+
# on Windows where helm returns a Windows path but we
13+
# need a Unix path
14+
if type cygpath > /dev/null; then
15+
HELM_PLUGIN=$(cygpath -u "$HELM_PLUGIN")
16+
fi
17+
18+
if [[ $SKIP_BIN_INSTALL == "1" ]]; then
19+
echo "Skipping binary install"
20+
exit
21+
fi
22+
23+
# initArch discovers the architecture for this system.
24+
initArch() {
25+
ARCH=$(uname -m)
26+
case $ARCH in
27+
armv5*) ARCH="armv5";;
28+
armv6*) ARCH="armv6";;
29+
armv7*) ARCH="armv7";;
30+
aarch64) ARCH="arm64";;
31+
x86) ARCH="386";;
32+
x86_64) ARCH="amd64";;
33+
i686) ARCH="386";;
34+
i386) ARCH="386";;
35+
esac
36+
}
37+
38+
# initOS discovers the operating system for this system.
39+
initOS() {
40+
OS=$(echo $(uname)|tr '[:upper:]' '[:lower:]')
41+
case "$OS" in
42+
# Msys support
43+
msys*) OS='windows';;
44+
# Minimalist GNU for Windows
45+
mingw*) OS='windows';;
46+
darwin) OS='macos';;
47+
esac
48+
}
49+
50+
# verifySupported checks that the os/arch combination is supported for
51+
# binary builds.
52+
verifySupported() {
53+
local supported="linux-amd64\nmacos-amd64\nwindows-amd64"
54+
if ! echo "${supported}" | grep -q "${OS}-${ARCH}"; then
55+
echo "No prebuild binary for ${OS}-${ARCH}."
56+
exit 1
57+
fi
58+
59+
if ! type "curl" > /dev/null && ! type "wget" > /dev/null; then
60+
echo "Either curl or wget is required"
61+
exit 1
62+
fi
63+
}
64+
65+
# getDownloadURL checks the latest available version.
66+
getDownloadURL() {
67+
# Use the GitHub API to find the latest version for this project.
68+
local latest_url="https://api.github.com/repos/$PROJECT_GH/releases/latest"
69+
if type "curl" > /dev/null; then
70+
DOWNLOAD_URL=$(curl -s $latest_url | grep $OS | awk '/\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}')
71+
elif type "wget" > /dev/null; then
72+
DOWNLOAD_URL=$(wget -q -O - $latest_url | awk '/\"browser_download_url\":/{gsub( /[,\"]/,"", $2); print $2}')
73+
fi
74+
}
75+
76+
# downloadFile downloads the latest binary package and also the checksum
77+
# for that binary.
78+
downloadFile() {
79+
PLUGIN_TMP_FILE="/tmp/${PROJECT_NAME}.tgz"
80+
echo "Downloading $DOWNLOAD_URL"
81+
if type "curl" > /dev/null; then
82+
curl -L "$DOWNLOAD_URL" -o "$PLUGIN_TMP_FILE"
83+
elif type "wget" > /dev/null; then
84+
wget -q -O "$PLUGIN_TMP_FILE" "$DOWNLOAD_URL"
85+
fi
86+
}
87+
88+
# installFile verifies the SHA256 for the file, then unpacks and
89+
# installs it.
90+
installFile() {
91+
HELM_TMP="/tmp/$PROJECT_NAME"
92+
mkdir -p "$HELM_TMP"
93+
tar xf "$PLUGIN_TMP_FILE" -C "$HELM_TMP"
94+
echo "$HELM_TMP"
95+
HELM_TMP_BIN="$HELM_TMP/helm-ssm"
96+
echo "Preparing to install into ${HELM_PLUGIN}"
97+
# Use * to also copy the file withe the exe suffix on Windows
98+
cp "$HELM_TMP_BIN"* "$HELM_PLUGIN"
99+
}
100+
101+
# fail_trap is executed if an error occurs.
102+
fail_trap() {
103+
result=$?
104+
if [ "$result" != "0" ]; then
105+
echo "Failed to install $PROJECT_NAME"
106+
echo "For support, go to https://github.com/codacy/helm-ssm."
107+
fi
108+
exit $result
109+
}
110+
111+
# testVersion tests the installed client to make sure it is working.
112+
testVersion() {
113+
set +e
114+
echo "$PROJECT_NAME installed into $HELM_PLUGIN/$PROJECT_NAME"
115+
# To avoid to keep track of the Windows suffix,
116+
# call the plugin assuming it is in the PATH
117+
PATH=$PATH:$HELM_PLUGIN
118+
helm-ssm -h
119+
set -e
120+
}
121+
122+
# Execution
123+
124+
#Stop execution on any error
125+
trap "fail_trap" EXIT
126+
set -e
127+
initArch
128+
initOS
129+
verifySupported
130+
getDownloadURL
131+
downloadFile
132+
installFile
133+
testVersion

plugin.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ ignoreFlags: false
77
useTunnel: false
88
command: "$HELM_PLUGIN_DIR/helm-ssm"
99
hooks:
10-
install: chmod +x $HELM_PLUGIN_DIR/helm-ssm
11-
update: chmod +x $HELM_PLUGIN_DIR/helm-ssm
10+
install: "$HELM_PLUGIN_DIR/install-binary.sh"
11+
update: "$HELM_PLUGIN_DIR/install-binary.sh"

0 commit comments

Comments
 (0)