Skip to content

Commit

Permalink
Add version option for gitlab-cli feature
Browse files Browse the repository at this point in the history
  • Loading branch information
schroedan committed Jan 31, 2025
1 parent 5c3bb5e commit 3487d7d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
12 changes: 11 additions & 1 deletion src/gitlab-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
{
"id": "gitlab-cli",
"version": "1.0.0",
"version": "1.1.0",
"name": "GitLab CLI",
"documentationURL": "https://github.com/skriptfabrik/devcontainer-features/tree/main/src/gitlab-cli",
"description": "Installs GitLab CLI (glab).",
"options": {
"version": {
"type": "string",
"proposals": [
"latest"
],
"default": "latest",
"description": "Select or enter a gitlab-cli version."
}
},
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
]
Expand Down
32 changes: 25 additions & 7 deletions src/gitlab-cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -e

CLI_VERSION="${VERSION:-"latest"}"

if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
Expand All @@ -18,14 +20,30 @@ fi

# Install prerequisites
apt-get -y update
apt-get -y install --no-install-recommends curl ca-certificates

# Add WakeMeOps repository
curl -sSL "https://raw.githubusercontent.com/upciti/wakemeops/main/assets/install_repository" | bash

# Install glab
apt-get -y install --no-install-recommends glab
apt-get -y install --no-install-recommends curl ca-certificates jq git

# Clean up
apt-get -y clean
rm -rf /var/lib/apt/lists/*

# Fetch latest version if needed
if [ "${CLI_VERSION}" = "latest" ]; then
CLI_VERSION=$(curl -s curl -s https://gitlab.com/api/v4/projects/34675721/releases | jq -r '.[0].tag_name' | awk '{print substr($1, 2)}')
fi

# Detect current machine architecture
if [ "$(uname -m)" = "aarch64" ]; then
ARCH="arm64"
else
ARCH="amd64"
fi

# DEB package and download URL
DEB_PACKAGE="glab_${CLI_VERSION}_linux_${ARCH}.deb"
DOWNLOAD_URL="https://gitlab.com/gitlab-org/cli/-/releases/v${CLI_VERSION}/downloads/${DEB_PACKAGE}"

# Download and install gitlab-cli
echo "Downloading gitlab-cli from ${DOWNLOAD_URL}"
curl -sSLO "${DOWNLOAD_URL}"
dpkg -i "${DEB_PACKAGE}"
rm -f "${DEB_PACKAGE}"

0 comments on commit 3487d7d

Please sign in to comment.