Last active
November 14, 2023 19:01
-
-
Save dotysan/c02714e7f81224a17ef01c51d6801c08 to your computer and use it in GitHub Desktop.
Install GitHub CLI on a Go-less system using Go in Docker
This file contains 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
#! /usr/bin/env bash | |
# | |
# Install GitHub CLI on a Go-less system using Go in Docker. | |
# | |
set -ex | |
# latest stable release | |
GHCLI_VER=v2.38.0 | |
GO_VER=1-bookworm | |
main() { | |
src | |
cd gh-cli.git | |
git switch --detach $GHCLI_VER | |
img | |
#bld | |
#tst | |
ins | |
cd .. | |
cln | |
} | |
src() { | |
! test -d gh-cli.git ||return 0 | |
git clone [email protected]:cli/cli.git gh-cli.git | |
} | |
img() { | |
docker build -t build-ghcli - <<-EOF | |
FROM golang:$GO_VER | |
# give make build proper perms in .:/gh-cli | |
RUN useradd --uid $UID --gid "${GROUPS[0]}" \ | |
--create-home --shell /bin/bash $USER | |
WORKDIR /gh-cli | |
EOF | |
} | |
bld() { | |
docker run --rm \ | |
--volume "$PWD:/gh-cli" \ | |
--user "$UID:${GROUPS[0]}" \ | |
build-ghcli \ | |
make | |
} | |
tst() { | |
docker run --rm \ | |
--volume "$PWD:/gh-cli" \ | |
--user "$UID:${GROUPS[0]}" \ | |
build-ghcli \ | |
make test | |
} | |
ins() { | |
docker run --rm \ | |
--volume "$PWD:/gh-cli" \ | |
--volume "$HOME/.local:/.local" \ | |
--user "$UID:${GROUPS[0]}" \ | |
build-ghcli \ | |
make install prefix=/.local | |
} | |
cln() { | |
rm --force --recursive gh-cli.git | |
docker image rm build-ghcli | |
} | |
main | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment