Skip to content

Commit 3487d7d

Browse files
committed
Add version option for gitlab-cli feature
1 parent 5c3bb5e commit 3487d7d

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

src/gitlab-cli/devcontainer-feature.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
{
22
"id": "gitlab-cli",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"name": "GitLab CLI",
55
"documentationURL": "https://github.com/skriptfabrik/devcontainer-features/tree/main/src/gitlab-cli",
66
"description": "Installs GitLab CLI (glab).",
7+
"options": {
8+
"version": {
9+
"type": "string",
10+
"proposals": [
11+
"latest"
12+
],
13+
"default": "latest",
14+
"description": "Select or enter a gitlab-cli version."
15+
}
16+
},
717
"installsAfter": [
818
"ghcr.io/devcontainers/features/common-utils"
919
]

src/gitlab-cli/install.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -e
44

5+
CLI_VERSION="${VERSION:-"latest"}"
6+
57
if [ "$(id -u)" -ne 0 ]; then
68
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
79
exit 1
@@ -18,14 +20,30 @@ fi
1820

1921
# Install prerequisites
2022
apt-get -y update
21-
apt-get -y install --no-install-recommends curl ca-certificates
22-
23-
# Add WakeMeOps repository
24-
curl -sSL "https://raw.githubusercontent.com/upciti/wakemeops/main/assets/install_repository" | bash
25-
26-
# Install glab
27-
apt-get -y install --no-install-recommends glab
23+
apt-get -y install --no-install-recommends curl ca-certificates jq git
2824

2925
# Clean up
3026
apt-get -y clean
3127
rm -rf /var/lib/apt/lists/*
28+
29+
# Fetch latest version if needed
30+
if [ "${CLI_VERSION}" = "latest" ]; then
31+
CLI_VERSION=$(curl -s curl -s https://gitlab.com/api/v4/projects/34675721/releases | jq -r '.[0].tag_name' | awk '{print substr($1, 2)}')
32+
fi
33+
34+
# Detect current machine architecture
35+
if [ "$(uname -m)" = "aarch64" ]; then
36+
ARCH="arm64"
37+
else
38+
ARCH="amd64"
39+
fi
40+
41+
# DEB package and download URL
42+
DEB_PACKAGE="glab_${CLI_VERSION}_linux_${ARCH}.deb"
43+
DOWNLOAD_URL="https://gitlab.com/gitlab-org/cli/-/releases/v${CLI_VERSION}/downloads/${DEB_PACKAGE}"
44+
45+
# Download and install gitlab-cli
46+
echo "Downloading gitlab-cli from ${DOWNLOAD_URL}"
47+
curl -sSLO "${DOWNLOAD_URL}"
48+
dpkg -i "${DEB_PACKAGE}"
49+
rm -f "${DEB_PACKAGE}"

0 commit comments

Comments
 (0)