-
-
Save santosh-gouda/3db3c4236d834775dcb2b6aaa46a051a to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env bash | |
| DBT_ENV=~/.virtualenvs/dbt | |
| DBT_BETA_ENV=~/.virtualenvs/dbt-beta | |
| process_environment() { | |
| env=$1 | |
| release=$2 | |
| if [[ -d "$env" ]]; then | |
| echo "" | |
| echo "There is an existing dbt environment in: $env" | |
| echo -n "Would you like to update(u) or reinstall(r)? [u/r]: " | |
| read ans | |
| if [[ $ans == "r" ]]; then | |
| echo "" | |
| echo "Reinstalling!" | |
| echo "Deleting existing environment" | |
| rm -rf $env && echo "Successfully deleted existing environment" | |
| elif [[ $ans = "u" ]]; then | |
| echo "Updating!" | |
| else | |
| echo "" | |
| echo "Exiting script" | |
| exit 1 | |
| fi | |
| fi | |
| echo "" | |
| echo "Creating dbt environment in: $env" | |
| python3 -m venv $env && echo "Successfully created dbt environment!" | |
| echo "" | |
| echo "Activating your dbt environment and installing the latest dbt version" | |
| if [[ $release == "stable" ]]; then | |
| source $env/bin/activate && pip install dbt -q -U && echo "Successfully installed dbt:" | |
| elif [[ $release == "pre" ]]; then | |
| source $env/bin/activate && pip install dbt -q -U --pre && echo "Successfully installed dbt:" | |
| else | |
| exit 1 | |
| fi | |
| dbt --version | |
| deactivate | |
| } | |
| echo "" | |
| echo "Initializing dbt environments" | |
| echo "" | |
| echo "=== main dbt environment ===" | |
| process_environment $DBT_ENV stable | |
| echo "" | |
| echo "=== dbt beta environment ===" | |
| process_environment $DBT_BETA_ENV pre | |
| echo "" | |
| echo "If you would like to get the commands to set your aliases" | |
| echo -n "to easily activate the environments respond with your shell or skip, [bash/zsh/skip]:" | |
| read ans_alias | |
| if [[ $ans_alias == "bash" ]]; then | |
| profile=~/.bash_profile | |
| elif [[ $release == "zsh" ]]; then | |
| profile=~/.zshrc | |
| else | |
| exit 1 | |
| fi | |
| echo "" | |
| echo "If you don't already have these aliases to quickly activate the dbt environments" | |
| echo "run the following commands in your terminal then restart your terminal:" | |
| echo "echo \"alias dbt-activate='source $DBT_ENV/bin/activate'\" >> $profile" | |
| echo "echo \"alias dbt-beta-activate='source $DBT_BETA_ENV/bin/activate'\" >> $profile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment