Skip to content

Commit

Permalink
install script
Browse files Browse the repository at this point in the history
  • Loading branch information
eightysteele committed Jul 19, 2024
1 parent fb236bf commit 9ffecd2
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 9 deletions.
Binary file added assets/test_results/just position.mp4
Binary file not shown.
Binary file added assets/test_results/position and color.mp4
Binary file not shown.
Binary file added assets/test_results/position color and width.mp4
Binary file not shown.
167 changes: 158 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,102 @@ __wrap__() {
fi
}

pixi-enable-autocomplete() {
pipx-installed() {
if command -v "$PIXI_BIN/pipx" &>/dev/null; then
return 0
else
return 1
fi
}

pipx-global-install() {
if pixi global install pipx; then
return 0
else
return 1
fi
}

keyring-installed() {
if command -v "$PIPX_BIN/keyring" &>/dev/null; then
return 0
else
return 1
fi
}

pipx-install-keyring() {
if pipx install keyring; then
return 0
else
return 1
fi
}

pipx-google-artifact-registry-injected() {
local backends=""
backends=$(keyring --list-backends)
if echo "$backends" | grep -q "keyrings.gauth.GooglePythonAuth"; then
return 0
else
return 1
fi
}

pipx-inject-google-artifact-registry() {
if pipx inject keyring \
keyrings.google-artifactregistry-auth \
--index-url https://pypi.org/simple \
--force; then
return 0
else
return 1
fi
}

gcloud-installed() {
if command -v "$PIXI_BIN/gcloud" &>/dev/null; then
return 0
else
return 1
fi
}

gcloud-global-install() {
if pixi global install google-cloud-sdk; then
return 0
else
return 1
fi
}

gcloud-authenticated() {
if [ "${GITHUB_CI:-}" = "true" ]; then
return 0
elif gcloud auth application-default print-access-token >/dev/null; then
return 0
else
return 1
fi
}

gcloud-init() {
if ! gcloud init; then
return 1
else
return 0
fi
}

gcloud-auth-adc() {
if ! gcloud auth application-default login; then
returny 1
else
return 0
fi
}

pixi-enable-autocomplete() {
local shell=$1
local config=$2

Expand Down Expand Up @@ -134,14 +229,68 @@ __wrap__() {

# setup google artifact registry access
echo "checking google artifact registry..."
pushd scripts &>/dev/null
./check-auth.sh
popd &>/dev/null

# if [ "${GITHUB_CI:-}" = "true" ]; then
# rm "$PIXI_BIN/pixi"
# return 0
# fi
# install pipx
echo "checking pipx..."
if ! pipx-installed; then
echo "installing pipx..."
if ! pipx-global-install; then
echo "couldn't install pipx"
exit 1
fi
fi
pipx ensurepath &>/dev/null
v=$(pipx --version)
p=$(which pipx)
printf " ✓ pipx %s installed (%s)\n\n" "$v" "$p"

# install keyring
echo "checking keyring..."
if ! keyring-installed; then
echo "installing keyring..."
if ! pipx-install-keyring; then
echo "pipx couldn't install keyring"
exit 1
fi
fi
p=$(which keyring)
printf " ✓ keyring installed (%s)\n\n" "$p"

# inject gcloud auth backend
echo "checking google-artifact-registry-auth keyring backend..."
if ! pipx-google-artifact-registry-injected; then
echo "injecting google-artifact-registry-auth backend..."
if ! pipx-inject-google-artifact-registry; then
echo "pipx couldn't inject google artifact registry keyring"
exit 1
fi
fi
printf " ✓ google artifact registry backend injected\n\n"

# install gcloud
echo "checking gcloud..."
if ! gcloud-installed; then
echo "installing gcloud..."
if ! gcloud-global-install; then
echo "gcloud install failed"
exit 1
fi
fi
v=$(gcloud --version)
p=$(which gcloud)
printf " ✓ gcloud %s installed (%s)\n\n" "$v" "$p"

# check gcloud auth
echo "checking gcloud auth..."
if ! gcloud-authenticated; then
echo "authenticating gcloud..."
if ! gcloud-auth-adc; then
echo "gcloud not authenticated"
exit 1
fi
fi
printf " ✓ gcloud authenticated\n\n"

printf "→ you are authenticated to google artifact registry \o/\n"

# install environment
echo "installing b3d project dependencies..."
Expand Down

0 comments on commit 9ffecd2

Please sign in to comment.