-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add installation script #772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1190c65
Add installation script
devm33 bbcca4a
Update installation instructions
devm33 d9c5018
Clean up leftover install dir
devm33 cf6859a
Grammar
devm33 4e028d9
Remove duplicate trailing slash
devm33 56c9ed8
Use tar -C instead of cd
devm33 f5f4c27
Always run mkdirp on install dir
devm33 82b6ca7
Fix download path check
devm33 5bf6153
Update install.sh
devm33 7c75e17
Update install.sh
devm33 b344a06
Document PREFIX
devm33 a77f445
Reorder for clarity maybe
devm33 6990535
Error to stderr
devm33 673aef0
Update install.sh
devm33 01b4b11
Update install.sh
devm33 fa43ed3
Clarify
devm33 6f30578
Add notice
devm33 8edeb17
Update install.sh
devm33 433ff32
Update install.sh
devm33 c7f74d9
Remove download dir
devm33 1b8ba1d
Document running as root with sudo
devm33 c068e98
Reorganize
devm33 fe9686a
Attempt to use winget
devm33 791b545
Add comment
devm33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| #!/usr/bin/env bash | ||
| set -e | ||
|
|
||
| # GitHub Copilot CLI Installation Script | ||
| # Usage: curl -fsSL https://gh.io/copilot-install | bash | ||
| # or: wget -qO- https://gh.io/copilot-install | bash | ||
| # Use | sudo bash to run as root and install to /usr/local/bin | ||
| # Export PREFIX to install to $PREFIX/bin/ directory (default: /usr/local for | ||
| # root, $HOME/.local for non-root), e.g., export PREFIX=$HOME/custom to install | ||
| # to $HOME/custom/bin | ||
|
|
||
| echo "Installing GitHub Copilot CLI..." | ||
|
|
||
| # Detect platform | ||
| case "$(uname -s || echo "")" in | ||
| Darwin*) PLATFORM="darwin" ;; | ||
| Linux*) PLATFORM="linux" ;; | ||
| *) | ||
| if command -v winget >/dev/null 2>&1; then | ||
| echo "Windows detected. Installing via winget..." | ||
| winget install GitHub.Copilot | ||
| exit $? | ||
| else | ||
| echo "Error: Windows detected but winget not found. Please see https://gh.io/install-copilot-readme" >&2 | ||
| exit 1 | ||
| fi | ||
| ;; | ||
| esac | ||
|
|
||
| # Detect architecture | ||
| case "$(uname -m)" in | ||
| x86_64|amd64) ARCH="x64" ;; | ||
| aarch64|arm64) ARCH="arm64" ;; | ||
| *) echo "Error: Unsupported architecture $(uname -m)" >&2 ; exit 1 ;; | ||
| esac | ||
|
|
||
| DOWNLOAD_URL="https://github.com/github/copilot-cli/releases/latest/download/copilot-${PLATFORM}-${ARCH}.tar.gz" | ||
| echo "Downloading from: $DOWNLOAD_URL" | ||
|
|
||
| # Download and extract with error handling | ||
| TMP_TARBALL="$(mktemp)" | ||
| if command -v curl >/dev/null 2>&1; then | ||
| curl -fsSL "$DOWNLOAD_URL" -o "$TMP_TARBALL" | ||
| elif command -v wget >/dev/null 2>&1; then | ||
| wget -qO "$TMP_TARBALL" "$DOWNLOAD_URL" | ||
| else | ||
| echo "Error: Neither curl nor wget found. Please install one of them." | ||
|
devm33 marked this conversation as resolved.
|
||
| exit 1 | ||
| fi | ||
|
|
||
| # Check that the file is a valid tarball | ||
| if ! tar -tzf "$TMP_TARBALL" >/dev/null 2>&1; then | ||
| echo "Error: Downloaded file is not a valid tarball or is corrupted." >&2 | ||
| rm -f "$TMP_TARBALL" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Check if running as root, fallback to non-root | ||
| if [ "$(id -u 2>/dev/null || echo 1)" -eq 0 ]; then | ||
|
devm33 marked this conversation as resolved.
|
||
| PREFIX="${PREFIX:-/usr/local}" | ||
| else | ||
| PREFIX="${PREFIX:-$HOME/.local}" | ||
|
devm33 marked this conversation as resolved.
|
||
| fi | ||
|
devm33 marked this conversation as resolved.
|
||
| INSTALL_DIR="$PREFIX/bin" | ||
| if ! mkdir -p "$INSTALL_DIR"; then | ||
| echo "Error: Could not create directory $INSTALL_DIR. You may not have write permissions." >&2 | ||
| echo "Try running this script with sudo or set PREFIX to a directory you own (e.g., export PREFIX=\$HOME/.local)." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Install binary | ||
| if [ -f "$INSTALL_DIR/copilot" ]; then | ||
| echo "Notice: Replacing copilot binary found at $INSTALL_DIR/copilot." | ||
| fi | ||
| tar -xz -C "$INSTALL_DIR" -f "$TMP_TARBALL" | ||
| chmod +x "$INSTALL_DIR/copilot" | ||
| echo "✓ GitHub Copilot CLI installed to $INSTALL_DIR/copilot" | ||
| rm -f "$TMP_TARBALL" | ||
|
|
||
| # Check if install directory is in PATH | ||
| case ":$PATH:" in | ||
| *":$INSTALL_DIR:"*) ;; | ||
| *) | ||
| echo "" | ||
| echo "Warning: $INSTALL_DIR is not in your PATH" | ||
| echo "Add it to your PATH by adding this line to your shell profile:" | ||
| echo " export PATH=\"\$PATH:$INSTALL_DIR\"" | ||
| ;; | ||
| esac | ||
|
|
||
| echo "" | ||
| echo "Installation complete! Run 'copilot help' to get started." | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.