Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
"azure-cli",
"common-utils",
"conda",
"copilot-cli",
"desktop-lite",
"docker-outside-of-docker",
"docker-in-docker",
Expand Down Expand Up @@ -70,6 +71,7 @@ jobs:
"azure-cli",
"common-utils",
"conda",
"copilot-cli",
"desktop-lite",
"docker-outside-of-docker",
"docker-in-docker",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand Down
7 changes: 7 additions & 0 deletions src/copilot-cli/NOTES.md
Original file line number Diff line number Diff line change
@@ -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.
31 changes: 31 additions & 0 deletions src/copilot-cli/README.md
Original file line number Diff line number Diff line change
@@ -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`._
33 changes: 33 additions & 0 deletions src/copilot-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"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"
],
"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"
]
}

82 changes: 82 additions & 0 deletions src/copilot-cli/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/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)
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}"

# 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
# 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
}

# Install the GitHub Copilot CLI
echo "Downloading GitHub Copilot CLI..."

install_using_github

5 changes: 5 additions & 0 deletions test/copilot-cli/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

echo "Checking if GitHub Copilot is installed..."
which copilot
copilot -v