From 1e68faf88c6ee475169cb2cfca40af6e2d9243c5 Mon Sep 17 00:00:00 2001 From: Devraj Mehta Date: Fri, 5 Dec 2025 16:10:55 -0500 Subject: [PATCH 1/6] Add feature for copilot-cli --- src/copilot-cli/NOTES.md | 7 +++ src/copilot-cli/README.md | 31 ++++++++++ src/copilot-cli/devcontainer-feature.json | 34 +++++++++++ src/copilot-cli/install.sh | 71 +++++++++++++++++++++++ test/copilot-cli/test.sh | 5 ++ 5 files changed, 148 insertions(+) create mode 100644 src/copilot-cli/NOTES.md create mode 100644 src/copilot-cli/README.md create mode 100644 src/copilot-cli/devcontainer-feature.json create mode 100755 src/copilot-cli/install.sh create mode 100644 test/copilot-cli/test.sh diff --git a/src/copilot-cli/NOTES.md b/src/copilot-cli/NOTES.md new file mode 100644 index 000000000..c5393ab5a --- /dev/null +++ b/src/copilot-cli/NOTES.md @@ -0,0 +1,7 @@ + + +## OS Support + +This Feature should work on recent versions of Debian/Ubuntu-based distributions. + +`bash` is required to execute the `install.sh` script. diff --git a/src/copilot-cli/README.md b/src/copilot-cli/README.md new file mode 100644 index 000000000..3b7fc3be5 --- /dev/null +++ b/src/copilot-cli/README.md @@ -0,0 +1,31 @@ + +# GitHub Copilot CLI (copilot-cli) + +Installs the GitHub Copilot CLI. Auto-detects latest version and installs needed dependencies. + +## Example Usage + +```json +"features": { + "ghcr.io/devcontainers/features/copilot-cli:1": {} +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| +| version | Select version of the GitHub Copilot CLI, if not latest. | string | latest | + + + +## OS Support + +This Feature should work on recent versions of Debian/Ubuntu-based distributions. + +`bash` is required to execute the `install.sh` script. + + +--- + +_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/devcontainers/features/blob/main/src/copilot-cli/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ \ No newline at end of file diff --git a/src/copilot-cli/devcontainer-feature.json b/src/copilot-cli/devcontainer-feature.json new file mode 100644 index 000000000..f0a73ab2a --- /dev/null +++ b/src/copilot-cli/devcontainer-feature.json @@ -0,0 +1,34 @@ +{ + "id": "copilot-cli", + "version": "1.0.0", + "name": "GitHub Copilot CLI", + "documentationURL": "https://github.com/devcontainers/features/tree/main/src/copilot-cli", + "description": "Installs the GitHub Copilot CLI.", + "options": { + "version": { + "type": "string", + "proposals": [ + "latest", + "prerelease", + "none" + ], + "default": "latest", + "description": "Select version of the GitHub Copilot CLI, if not latest." + } + }, + "customizations": { + "vscode": { + "settings": { + "github.copilot.chat.codeGeneration.instructions": [ + { + "text": "This dev container includes the GitHub Copilot CLI (`copilot`), which is pre-installed and available on the `PATH`." + } + ] + } + } + }, + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils" + ] +} + diff --git a/src/copilot-cli/install.sh b/src/copilot-cli/install.sh new file mode 100755 index 000000000..4a7878513 --- /dev/null +++ b/src/copilot-cli/install.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +# Docs: https://github.com/devcontainers/features/blob/main/src/copilot-cli/README.md +# Maintainer: The VS Code and Codespaces Teams + +CLI_VERSION=${VERSION:-"latest"} + +set -e + +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 +fi + +apt_get_update() { + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} + +# Checks if packages are installed and installs them if not +check_packages() { + if ! dpkg -s "$@" > /dev/null 2>&1; then + apt_get_update + apt-get -y install --no-install-recommends "$@" + fi +} + +download_from_github() { + local release_url=$1 + echo "Downloading GitHub Copilot CLI from ${release_url}..." + + mkdir -p /tmp/copilotcli + pushd /tmp/copilotcli + wget --show-progress --progress=dot:giga ${release_url} + # curl -fL# -O ${release_url} + tar -xzf /tmp/copilotcli/${cli_filename} + mv copilot /usr/local/bin/copilot + popd + rm -rf /tmp/copilotcli +} + +install_using_github() { + check_packages wget tar ca-certificates git + echo "Finished setting up dependencies" + arch=$(dpkg --print-architecture) + cli_filename="copilot-linux-${arch}.tar.gz" + echo "Installing GitHub Copilot CLI for ${arch} architecture: ${cli_filename}" + + # Install latest + if [ "${CLI_VERSION}" = "latest" ]; then + download_from_github "https://github.com/github/copilot-cli/releases/latest/download/${cli_filename}" + elif [ "${CLI_VERSION}" = "prerelease" ]; then + prerelease_version="$(git ls-remote --tags https://github.com/github/copilot-cli | tail -1 | awk -F/ '{print $NF}')" + download_from_github "https://github.com/github/copilot-cli/releases/download/${prerelease_version}/${cli_filename}" + else + echo "Unsupported version value: ${CLI_VERSION}, falling back to latest" >&2 + download_from_github "https://github.com/github/copilot-cli/releases/latest/download/${cli_filename}" + fi +} + +# Install the GitHub Copilot CLI +echo "Downloading GitHub Copilot CLI..." + +install_using_github + diff --git a/test/copilot-cli/test.sh b/test/copilot-cli/test.sh new file mode 100644 index 000000000..d1d624cda --- /dev/null +++ b/test/copilot-cli/test.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +echo "Checking if GitHub Copilot is installed..." +which copilot +copilot -v \ No newline at end of file From a2cd1fb8a3f4445653c8e2d570979024488d20fc Mon Sep 17 00:00:00 2001 From: Devraj Mehta Date: Mon, 8 Dec 2025 10:43:45 -0500 Subject: [PATCH 2/6] Add copilot-cli to CI workflows for testing --- .github/workflows/test-all.yaml | 2 ++ .github/workflows/test-pr.yaml | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index 7e4c343bd..ea4fe8728 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -17,6 +17,7 @@ jobs: "azure-cli", "common-utils", "conda", + "copilot-cli", "desktop-lite", "docker-outside-of-docker", "docker-in-docker", @@ -70,6 +71,7 @@ jobs: "azure-cli", "common-utils", "conda", + "copilot-cli", "desktop-lite", "docker-outside-of-docker", "docker-in-docker", diff --git a/.github/workflows/test-pr.yaml b/.github/workflows/test-pr.yaml index c5930d97e..645d38109 100644 --- a/.github/workflows/test-pr.yaml +++ b/.github/workflows/test-pr.yaml @@ -17,6 +17,7 @@ jobs: azure-cli: ./**/azure-cli/** common-utils: ./**/common-utils/** conda: ./**/conda/** + copilot-cli: ./**/copilot-cli/** desktop-lite: ./**/desktop-lite/** docker-outside-of-docker: ./**/docker-outside-of-docker/** docker-in-docker: ./**/docker-in-docker/** From 4ffb8b258a503308d9a0e4082e74178b3b6b0596 Mon Sep 17 00:00:00 2001 From: Devraj Mehta Date: Mon, 8 Dec 2025 10:48:49 -0500 Subject: [PATCH 3/6] Add check for supported arch and fix remote name for amd64 --- src/copilot-cli/install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/copilot-cli/install.sh b/src/copilot-cli/install.sh index 4a7878513..1484fc857 100755 --- a/src/copilot-cli/install.sh +++ b/src/copilot-cli/install.sh @@ -49,6 +49,13 @@ install_using_github() { check_packages wget tar ca-certificates git echo "Finished setting up dependencies" arch=$(dpkg --print-architecture) + if [ "${arch}" = "amd64" ]; then + arch="x64" + fi + if [ "${arch}" != "x64" ] && [ "${arch}" != "arm64" ]; then + echo "Unsupported architecture: ${arch}" >&2 + exit 1 + fi cli_filename="copilot-linux-${arch}.tar.gz" echo "Installing GitHub Copilot CLI for ${arch} architecture: ${cli_filename}" From d3d47382652166f43578579a914a2991423d7700 Mon Sep 17 00:00:00 2001 From: Devraj Mehta Date: Mon, 8 Dec 2025 11:59:41 -0500 Subject: [PATCH 4/6] Remove none --- src/copilot-cli/devcontainer-feature.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/copilot-cli/devcontainer-feature.json b/src/copilot-cli/devcontainer-feature.json index f0a73ab2a..ab433e2ae 100644 --- a/src/copilot-cli/devcontainer-feature.json +++ b/src/copilot-cli/devcontainer-feature.json @@ -9,8 +9,7 @@ "type": "string", "proposals": [ "latest", - "prerelease", - "none" + "prerelease" ], "default": "latest", "description": "Select version of the GitHub Copilot CLI, if not latest." From 008ff148c938523a0603f3156b4896c30ac9c246 Mon Sep 17 00:00:00 2001 From: Devraj Mehta Date: Mon, 8 Dec 2025 11:59:44 -0500 Subject: [PATCH 5/6] Allow pinning a specific version --- src/copilot-cli/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/copilot-cli/install.sh b/src/copilot-cli/install.sh index 1484fc857..834aa1221 100755 --- a/src/copilot-cli/install.sh +++ b/src/copilot-cli/install.sh @@ -66,8 +66,8 @@ install_using_github() { prerelease_version="$(git ls-remote --tags https://github.com/github/copilot-cli | tail -1 | awk -F/ '{print $NF}')" download_from_github "https://github.com/github/copilot-cli/releases/download/${prerelease_version}/${cli_filename}" else - echo "Unsupported version value: ${CLI_VERSION}, falling back to latest" >&2 - download_from_github "https://github.com/github/copilot-cli/releases/latest/download/${cli_filename}" + # Install specific version + download_from_github "https://github.com/github/copilot-cli/releases/download/${CLI_VERSION}/${cli_filename}" fi } From a6ae2bb884758494a024b5e070093b57708f7b1e Mon Sep 17 00:00:00 2001 From: Devraj Mehta Date: Mon, 8 Dec 2025 12:07:13 -0500 Subject: [PATCH 6/6] Add leading v for pinned versions --- src/copilot-cli/install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/copilot-cli/install.sh b/src/copilot-cli/install.sh index 834aa1221..7250fa642 100755 --- a/src/copilot-cli/install.sh +++ b/src/copilot-cli/install.sh @@ -67,6 +67,10 @@ install_using_github() { download_from_github "https://github.com/github/copilot-cli/releases/download/${prerelease_version}/${cli_filename}" else # Install specific version + # Add leading v to version if it doesn't start with v + if [[ ! "${CLI_VERSION}" =~ ^v[0-9] ]]; then + CLI_VERSION="v${CLI_VERSION}" + fi download_from_github "https://github.com/github/copilot-cli/releases/download/${CLI_VERSION}/${cli_filename}" fi }