Skip to content
This repository was archived by the owner on Jun 4, 2025. It is now read-only.

Commit 5db8928

Browse files
committed
add script to install the latest version of jsctl
Signed-off-by: Tim Ramlot <[email protected]>
1 parent ad2d06a commit 5db8928

File tree

3 files changed

+135
-17
lines changed

3 files changed

+135
-17
lines changed

.goreleaser.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ builds:
1616
- linux
1717
goarch:
1818
- amd64
19-
- arm
2019
- arm64
2120
- id: "darwin"
2221
env:
@@ -45,41 +44,29 @@ builds:
4544
- windows
4645
goarch:
4746
- amd64
48-
- "386"
4947
- arm64
5048
archives:
5149
- id: linux
5250
format: tar.gz
53-
name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
51+
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
5452
wrap_in_directory: true
5553
builds:
5654
- "linux"
57-
replacements:
58-
arm: armv7l
59-
arm64: aarch64
60-
amd64: x86_64
6155
- id: darwin
6256
format: tar.gz
63-
name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
57+
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
6458
wrap_in_directory: true
6559
builds:
6660
- "darwin"
67-
replacements:
68-
arm: armv7l
69-
amd64: x86_64
7061
- id: windows
7162
format: tar.gz
72-
name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
63+
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
7364
wrap_in_directory: true
7465
builds:
7566
- "windows"
76-
replacements:
77-
arm64: Arm64
78-
amd64: 64bit
79-
386: 32bit
8067

8168
checksum:
82-
name_template: "{{ .ProjectName }}-{{ .Version }}-SHA256SUMS"
69+
name_template: "{{ .ProjectName }}-SHA256SUMS"
8370
algorithm: sha256
8471
release:
8572
draft: true

install.ps1

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env pwsh
2+
3+
$ErrorActionPreference = 'Stop'
4+
5+
$JsctlInstall = $env:JSCTL_INSTALL
6+
$BinDir = if ($JsctlInstall) {
7+
"${JsctlInstall}\bin"
8+
} else {
9+
"${Home}\.jsctl\bin"
10+
}
11+
12+
$JsctlTar = "$BinDir\jsctl.tar.gz"
13+
$JsctlExe = "$BinDir\jsctl.exe"
14+
15+
$Target = if ($ENV:OS -eq "Windows_NT") {
16+
$arch = if ($ENV:PROCESSOR_ARCHITEW6432) {
17+
$ENV:PROCESSOR_ARCHITEW6432
18+
} else {
19+
$ENV:PROCESSOR_ARCHITECTURE
20+
}
21+
22+
switch ($arch) {
23+
"AMD64" { "jsctl-amd64-windows" }
24+
"ARM64" { "jsctl-arm64-windows" }
25+
default { throw "Error: Unsupported windows achitecture: ${arch}" }
26+
}
27+
} else {
28+
throw "Error: Unsupported operating system, use the install.sh script instead."
29+
}
30+
31+
$DownloadUrl = "https://github.com/jetstack/jsctl/releases/latest/download/${Target}.tar.gz"
32+
33+
if (!(Test-Path $BinDir)) {
34+
New-Item $BinDir -ItemType Directory | Out-Null
35+
}
36+
37+
curl.exe --fail --location --progress-bar --output $JsctlTar $DownloadUrl
38+
39+
tar.exe -x -C $BinDir -f $JsctlTar "$Target/jsctl.exe"
40+
41+
Move-Item -Path "$BinDir\$Target\jsctl.exe" -Destination $JsctlExe -Force
42+
43+
Remove-Item "$BinDir\$Target\"
44+
Remove-Item $JsctlTar
45+
46+
$User = [System.EnvironmentVariableTarget]::User
47+
$Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
48+
if (!(";${Path};".ToLower() -like "*;${BinDir};*".ToLower())) {
49+
[System.Environment]::SetEnvironmentVariable('Path', "${Path};${BinDir}", $User)
50+
$Env:Path += ";${BinDir}"
51+
}
52+
53+
Write-Output "jsctl was installed successfully to ${JsctlExe}"
54+
Write-Output "Run 'jsctl --help' to get started"
55+
Write-Output "Checkout https://platform.jetstack.io/documentation for more information"

install.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
if ! command -v tar >/dev/null; then
6+
echo "Error: tar is required to install jsctl" 1>&2
7+
exit 1
8+
fi
9+
10+
if ! command -v curl >/dev/null; then
11+
echo "Error: curl is required to install jsctl" 1>&2
12+
exit 1
13+
fi
14+
15+
if [ "$OS" = "Windows_NT" ]; then
16+
if [ -z "$PROCESSOR_ARCHITEW6432" ]; then
17+
arch="$PROCESSOR_ARCHITECTURE"
18+
else
19+
arch="$PROCESSOR_ARCHITEW6432"
20+
fi
21+
22+
case $arch in
23+
"AMD64") target="jsctl-amd64-windows" ;;
24+
"ARM64") target="jsctl-arm64-windows" ;;
25+
*)
26+
echo "Error: Unsupported windows achitecture: ${arch}" 1>&2
27+
exit 1 ;;
28+
esac
29+
target_file="jsctl.exe"
30+
else
31+
case $(uname -sm) in
32+
"Darwin x86_64") target="jsctl-amd64-darwin" ;;
33+
"Darwin arm64") target="jsctl-arm64-darwin" ;;
34+
"Linux x86_64") target="jsctl-amd64-linux" ;;
35+
"Linux aarch64") target="jsctl-arm64-linux" ;;
36+
*)
37+
echo "Error: Unsupported operating system or architecture: $(uname -sm)" 1>&2
38+
exit 1 ;;
39+
esac
40+
target_file="jsctl"
41+
fi
42+
43+
jsctl_uri="https://github.com/jetstack/jsctl/releases/latest/download/${target}.tar.gz"
44+
45+
jsctl_install="${JSCTL_INSTALL:-$HOME/.jsctl}"
46+
bin_dir="$jsctl_install/bin"
47+
bin="$bin_dir/$target_file"
48+
49+
if [ ! -d "$bin_dir" ]; then
50+
mkdir -p "$bin_dir"
51+
fi
52+
53+
curl --fail --location --progress-bar --output "$bin.tar.gz" "$jsctl_uri"
54+
tar xfO "$bin.tar.gz" "$target/$target_file" > "$bin"
55+
chmod +x "$bin"
56+
rm "$bin.tar.gz"
57+
58+
echo "jsctl was installed successfully to $bin"
59+
if command -v jsctl >/dev/null; then
60+
echo "Run 'jsctl --help' to get started"
61+
else
62+
case $SHELL in
63+
/bin/zsh) shell_profile=".zshrc" ;;
64+
*) shell_profile=".bashrc" ;;
65+
esac
66+
echo
67+
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
68+
echo " export JSCTL_INSTALL=\"$jsctl_install\""
69+
echo " export PATH=\"\$JSCTL_INSTALL/bin:\$PATH\""
70+
echo
71+
echo "And run \"source $HOME/.bashrc\" to update your current shell"
72+
echo
73+
echo "Run '$bin --help' to get started"
74+
fi
75+
echo
76+
echo "Checkout https://platform.jetstack.io/documentation for more information"

0 commit comments

Comments
 (0)