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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
"dotnet",
"eclipse-deps",
"git-lfs",
"github-copilot-cli",
"gitlab-cli",
"go",
"gonovate",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Below is a list with included features, click on the link for more details.
| [dotnet](./features/src/dotnet/README.md) | A package which installs .NET SDKs, runtimes and workloads. |
| [eclipse-deps](./features/src/eclipse-deps/README.md) | Installs all dependencies required to run the Eclipse IDE. |
| [git-lfs](./features/src/git-lfs/README.md) | Installs Git LFS. |
| [github-copilot-cli](./features/src/github-copilot-cli/README.md) | Installs GitHub Copilot CLI (copilot), the AI-powered coding assistant for the terminal. |
| [gitlab-cli](./features/src/gitlab-cli/README.md) | Installs the GitLab CLI. |
| [go](./features/src/go/README.md) | Installs Go. |
| [gonovate](./features/src/gonovate/README.md) | Installs Gonovate. |
Expand Down
4 changes: 4 additions & 0 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ func init() {
gotaskr.Task("Feature:git-lfs:Package", func() error { return packageFeature("git-lfs") })
gotaskr.Task("Feature:git-lfs:Test", func() error { return testFeature("git-lfs") })

////////// github-copilot-cli
gotaskr.Task("Feature:github-copilot-cli:Package", func() error { return packageFeature("github-copilot-cli") })
gotaskr.Task("Feature:github-copilot-cli:Test", func() error { return testFeature("github-copilot-cli") })

////////// gitlab-cli
gotaskr.Task("Feature:gitlab-cli:Package", func() error { return packageFeature("gitlab-cli") })
gotaskr.Task("Feature:gitlab-cli:Test", func() error { return testFeature("gitlab-cli") })
Expand Down
13 changes: 13 additions & 0 deletions features/src/github-copilot-cli/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Notes

### System Compatibility

Debian, Ubuntu

### Accessed Urls

Needs access to the following URL for downloading:
* https://github.com

Needs access to the following URL for resolving:
* https://api.github.com
35 changes: 35 additions & 0 deletions features/src/github-copilot-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# GitHub Copilot CLI (github-copilot-cli)

Installs GitHub Copilot CLI (copilot), the AI-powered coding assistant for the terminal.

## Example Usage

```json
"features": {
"ghcr.io/postfinance/devcontainer-features/github-copilot-cli:1.0.0": {
"version": "latest",
"downloadUrl": ""
}
}
```

## Options

| Option | Description | Type | Default Value | Proposals |
|-----|-----|-----|-----|-----|
| version | The version of GitHub Copilot CLI to install. | string | latest | latest, 1.0.39 |
| downloadUrl | The download URL to use for GitHub Copilot CLI binaries. | string | <empty> | https://mycompany.com/artifactory/github-releases-remote |

## Notes

### System Compatibility

Debian, Ubuntu

### Accessed Urls

Needs access to the following URL for downloading:
* https://github.com

Needs access to the following URL for resolving:
* https://api.github.com
25 changes: 25 additions & 0 deletions features/src/github-copilot-cli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": "github-copilot-cli",
"version": "1.0.0",
"name": "GitHub Copilot CLI",
"description": "Installs GitHub Copilot CLI (copilot), the AI-powered coding assistant for the terminal.",
"options": {
"version": {
"type": "string",
"proposals": [
"latest",
"1.0.39"
],
"default": "latest",
"description": "The version of GitHub Copilot CLI to install."
},
"downloadUrl": {
"type": "string",
"default": "",
"proposals": [
"https://mycompany.com/artifactory/github-releases-remote"
],
"description": "The download URL to use for GitHub Copilot CLI binaries."
}
}
}
5 changes: 5 additions & 0 deletions features/src/github-copilot-cli/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
. ./functions.sh

"./installer_$(detect_arch)" \
-version="${VERSION:-"latest"}" \
-downloadUrl="${DOWNLOADURL:-""}"
108 changes: 108 additions & 0 deletions features/src/github-copilot-cli/installer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package main

import (
"builder/installer"
"flag"
"fmt"
"os"
"path/filepath"
"regexp"

"github.com/roemer/gover"
)

//////////
// Configuration
//////////

var versionRegex *regexp.Regexp = regexp.MustCompile(`(?m)^v(?P<raw>(\d+)\.(\d+)\.(\d+))$`)

//////////
// Main
//////////

func main() {
if err := runMain(); err != nil {
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
}

func runMain() error {
// Handle the flags
version := flag.String("version", "latest", "")
downloadUrl := flag.String("downloadUrl", "", "")
flag.Parse()

// Load settings from an external file
if err := installer.LoadOverrides(); err != nil {
return err
}

// Apply override logic for URLs
installer.HandleGitHubOverride(downloadUrl, "github/copilot-cli", "github-copilot-cli-download-url")

// Create and process the feature
feature := installer.NewFeature("GitHub Copilot CLI", false,
&githubCopilotCliComponent{
ComponentBase: installer.NewComponentBase("GitHub Copilot CLI", *version),
DownloadUrl: *downloadUrl,
})
return feature.Process()
}

//////////
// Implementation
//////////

type githubCopilotCliComponent struct {
*installer.ComponentBase
DownloadUrl string
}

func (c *githubCopilotCliComponent) GetAllVersions() ([]*gover.Version, error) {
tags, err := installer.Tools.GitHub.GetTags("github", "copilot-cli")
if err != nil {
return nil, err
}
return installer.Tools.Versioning.ParseVersionsFromList(tags, versionRegex, true)
}

func (c *githubCopilotCliComponent) InstallVersion(version *gover.Version) error {
archPart, err := installer.Tools.System.MapArchitecture(map[string]string{
installer.AMD64: "x64",
installer.ARM64: "arm64",
})
if err != nil {
return err
}

// Download the archive
fileName := fmt.Sprintf("copilot-linux-%s.tar.gz", archPart)
downloadUrl, err := installer.Tools.Http.BuildUrl(c.DownloadUrl, "v"+version.Raw, fileName)
if err != nil {
return err
}
if err := installer.Tools.Download.ToFile(downloadUrl, fileName, "GitHub Copilot CLI"); err != nil {
return err
}
defer os.Remove(fileName)

// Extract to a temp directory
tempDir, err := os.MkdirTemp("", "github-copilot-cli-extract")
if err != nil {
return err
}
defer os.RemoveAll(tempDir)

if err := installer.Tools.Compression.ExtractTarGz(fileName, tempDir, false); err != nil {
return err
}

// Install the binary
if err := installer.Tools.System.InstallBinaryToUsrLocalBin(filepath.Join(tempDir, "copilot"), "copilot"); err != nil {
return err
}

return nil
}
8 changes: 8 additions & 0 deletions features/test/github-copilot-cli/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

[[ -f "$(dirname "$0")/../functions.sh" ]] && source "$(dirname "$0")/../functions.sh"
[[ -f "$(dirname "$0")/functions.sh" ]] && source "$(dirname "$0")/functions.sh"

check_file_exists "/usr/local/bin/copilot"
check_version "$(copilot --version)" "1.0.39"
15 changes: 15 additions & 0 deletions features/test/github-copilot-cli/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"install": {
"build": {
"dockerfile": "Dockerfile",
"options": [
"--add-host=host.docker.internal:host-gateway"
]
},
"features": {
"./github-copilot-cli": {
"version": "1.0.39"
}
}
}
}
5 changes: 5 additions & 0 deletions features/test/github-copilot-cli/test-images.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
"mcr.microsoft.com/devcontainers/base:debian-11",
"mcr.microsoft.com/devcontainers/base:debian-12",
"mcr.microsoft.com/devcontainers/base:ubuntu-24.04"
]
3 changes: 3 additions & 0 deletions override-all.env
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ DOTNET_NUGET_CONFIG_PATH=""
# git-lfs
GIT_LFS_DOWNLOAD_URL=""

# github-copilot-cli
GITHUB_COPILOT_CLI_DOWNLOAD_URL=""

# gitlab-cli
GITLAB_CLI_DOWNLOAD_URL=""
GITLAB_CLI_VERSIONS_URL=""
Expand Down