Skip to content

Commit 13e3204

Browse files
authored
Merge pull request #58 from rio/feat/chew-bubble-gum
feat: chew bubble gum
2 parents e9aba36 + 056e6e8 commit 13e3204

9 files changed

Lines changed: 149 additions & 0 deletions

File tree

.github/workflows/test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
matrix:
1515
features:
1616
- chezmoi
17+
- gum
1718
- k3d
1819
- k9s
1920
- kustomize

src/gum/devcontainer-feature.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "gum",
3+
"id": "gum",
4+
"version": "1.0.0",
5+
"description": "A tool for glamorous shell scripts.",
6+
"options": {
7+
"version": {
8+
"type": "string",
9+
"default": "latest",
10+
"description": "Version of gum to install. Accepts versions with or without the 'v' prefix."
11+
}
12+
}
13+
}

src/gum/install.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# grab the version
5+
readonly GUM_VERSION="${VERSION:-latest}"
6+
7+
# apt-get configuration
8+
export DEBIAN_FRONTEND=noninteractive
9+
10+
11+
preflight () {
12+
if command -v wget > /dev/null; then
13+
return
14+
fi
15+
16+
if [ -e /etc/os-release ]; then
17+
. /etc/os-release
18+
fi
19+
20+
case "${ID}" in
21+
'debian' | 'ubuntu')
22+
apt-get update
23+
apt-get install -y --no-install-recommends \
24+
wget \
25+
ca-certificates
26+
;;
27+
'fedora')
28+
dnf -y install wget
29+
;;
30+
*) echo "The ${ID} distribution is not supported."; exit 1 ;;
31+
esac
32+
}
33+
34+
main () {
35+
preflight
36+
37+
local ARCH="$(uname -m)"
38+
case "${ARCH}" in
39+
"aarch64") ARCH="arm64" ;;
40+
"x86_64") ARCH="x86_64" ;;
41+
*) echo "The current architecture (${ARCH}) is not supported."; exit 1 ;;
42+
esac
43+
44+
if [ "${GUM_VERSION}" != "latest" ] ; then
45+
GUM_CHECKSUMS_URL="https://github.com/charmbracelet/gum/releases/download/v${GUM_VERSION#[vV]}/checksums.txt"
46+
GUM_URL="https://github.com/charmbracelet/gum/releases/download/v${GUM_VERSION#[vV]}/gum_${GUM_VERSION#[vV]}_Linux_${ARCH}.tar.gz"
47+
else
48+
local RELEASES_RESPONSE="$(wget -qO- --tries=3 https://api.github.com/repos/charmbracelet/gum/releases)"
49+
GUM_CHECKSUMS_URL="$(echo "${RELEASES_RESPONSE}" | grep "browser_download_url.*checksums.txt" | head -n 1 | cut -d '"' -f 4)"
50+
GUM_URL="$(echo "${RELEASES_RESPONSE}" | grep "browser_download_url.*Linux_${ARCH}.tar.gz" | head -n 1 | cut -d '"' -f 4)"
51+
fi
52+
53+
echo "Installing gum ${GUM_VERSION} for ${ARCH} ..."
54+
55+
echo "Downloading checksums ${GUM_CHECKSUMS_URL} ..."
56+
wget --no-verbose -O /tmp/checksums.txt "${GUM_CHECKSUMS_URL}"
57+
local GUM_SHA="$(grep Linux_${ARCH}.tar.gz$ /tmp/checksums.txt | cut -d ' ' -f 1)"
58+
59+
echo "Downloading ${GUM_URL} ..."
60+
wget --no-verbose -O /tmp/gum.tar.gz "${GUM_URL}"
61+
62+
echo "Verifying checksum ${GUM_SHA} ..."
63+
echo "${GUM_SHA} /tmp/gum.tar.gz" | sha256sum -c -
64+
65+
echo "Extracting..."
66+
tar xf /tmp/gum.tar.gz --directory=/usr/local/bin --strip-components=1 --wildcards gum_*_Linux_${ARCH}/gum
67+
chmod +x /usr/local/bin/gum
68+
rm /tmp/gum.tar.gz
69+
70+
echo "gum ${GUM_VERSION} for ${ARCH} installed at $(command -v gum)."
71+
}
72+
73+
main "$@"

test/_global/all-tools.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ source dev-container-features-test-lib
99
# The 'check' command comes from the dev-container-features-test-lib.
1010
check "skaffold" skaffold version
1111
check "chezmoi" chezmoi --version
12+
check "gum" gum --version
1213
check "kustomize" kustomize version
1314
check "k9s" k9s version
1415
check "k3d" k3d version

test/_global/scenarios.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"features": {
55
"chezmoi": {},
66
"skaffold": {},
7+
"gum": {},
78
"k9s": {},
89
"k3d": {},
910
"kustomize": {},
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library bundled with the devcontainer CLI
6+
source dev-container-features-test-lib
7+
8+
# Feature-specific tests
9+
# The 'check' command comes from the dev-container-features-test-lib.
10+
check "gum specific version v0.16.1" /bin/bash -c "gum --version | grep 'v0.16.1'"
11+
12+
# Report result
13+
# If any of the checks above exited with a non-zero exit code, the test will fail.
14+
reportResults
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library bundled with the devcontainer CLI
6+
source dev-container-features-test-lib
7+
8+
# Feature-specific tests
9+
# The 'check' command comes from the dev-container-features-test-lib.
10+
check "gum specific version .16.1" /bin/bash -c "gum --version | grep 'v0.16.1'"
11+
12+
# Report result
13+
# If any of the checks above exited with a non-zero exit code, the test will fail.
14+
reportResults

test/gum/scenarios.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"gum-specific-version-without-prefix": {
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
"features": {
5+
"gum": {
6+
"version": "0.16.1"
7+
}
8+
}
9+
},
10+
"gum-specific-version-with-prefix": {
11+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
12+
"features": {
13+
"gum": {
14+
"version": "v0.16.1"
15+
}
16+
}
17+
}
18+
}

test/gum/test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Optional: Import test library bundled with the devcontainer CLI
6+
source dev-container-features-test-lib
7+
8+
# Feature-specific tests
9+
# The 'check' command comes from the dev-container-features-test-lib.
10+
check "gum" gum --version
11+
12+
# Report result
13+
# If any of the checks above exited with a non-zero exit code, the test will fail.
14+
reportResults

0 commit comments

Comments
 (0)