Skip to content

Commit

Permalink
Merge pull request warrensbox#125 from warrensbox/release
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
warrensbox authored Jun 23, 2022
2 parents 9cc4c53 + 07b165a commit 87fc4a7
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 62 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ jobs:
steps:

- name: Checkout Repository
uses: actions/checkout@master
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Checkout go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: '1.18' # The Go version to download (if necessary) and use.

Expand All @@ -39,28 +41,29 @@ jobs:
run: chmod 755 test-tgswitch.sh && ./test-tgswitch.sh

- name: Bump version and push tag
uses: anothrNick/github-tag-action@1.26.0
uses: anothrNick/github-tag-action@1.39.0
id: vars
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
INITIAL_VERSION: 0.6.0
RELEASE_BRANCHES: release
DEFAULT_BUMP: patch
DEFAULT_BUMP: minor

- name: Check output
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: |
echo $RELEASE_VERSION
echo ${{ steps.vars.outputs.tag }}
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.HOMEBREW_TOKEN_TGSWITCH }}
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
Expand Down
122 changes: 66 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,98 +7,131 @@
<img style="text-allign:center" src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/smallerlogo.png" alt="drawing" width="110" height="140"/>


The `tgswitch` command line tool lets you switch between different versions of [terragrunt](https://www.terragrunt.io/).
The `tgswitch` command line tool lets you switch between different versions of <a href="https://terragrunt.gruntwork.io/" target="_blank">terragrunt</a>.
If you do not have a particular version of terragrunt installed, `tgswitch` will download the version you desire.
The installation is minimal and easy.
Once installed, simply select the version you require from the dropdown and start using terragrunt.


See installation guide here: [tgswitch installation](https://warrensbox.github.io/tgswitch/)

***Important**
Please see upcoming changes [Version 0.5](CHANGELOG.md)

## Installation

`tgswitch` is available for MacOS and Linux based operating systems.

### Homebrew

Installation for MacOS is the easiest with Homebrew. [If you do not have homebrew installed, click here](https://brew.sh/).

Installation for MacOS is the easiest with Homebrew. <a href="https://brew.sh/" target="_blank">If you do not have homebrew installed, click here</a>.

```ruby
brew install warrensbox/tap/tgswitch
```

### Linux

Installation for other linux operation systems.
Installation for Linux operation systems.

```sh
curl -L https://raw.githubusercontent.com/warrensbox/tgswitch/release/install.sh | bash
```

### Install from source

Alternatively, you can install the binary from source [here](https://github.com/warrensbox/tgswitch/releases)
Alternatively, you can install the binary from the source <a href="https://github.com/warrensbox/tgswitch/releases" target="_blank">here</a>.

[Having trouble installing](https://tgswitch.warrensbox.com/Troubleshoot/).
## How to use:
### Use dropdown menu to select version
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/tgswitch.gif" alt="drawing" style="width: 180px;"/>
<img src="https://kepler-images.s3.us-east-2.amazonaws.com/warrensbox/tgswitch/tgswitch_v1.gif" alt="drawing" style="width: 600px;"/>

1. You can switch between different versions of terragrunt by typing the command `tgswitch` on your terminal.
1. You can switch between different versions of terragrunt by typing the command `tgswitch` on your terminal.
2. Select the version of terragrunt you require by using the up and down arrow.
3. Hit **Enter** to select the desired version.

The most recently selected versions are presented at the top of the dropdown.

### Supply version on command line
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/tgswitch-v4.gif" alt="drawing" style="width: 170px;"/>
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/tgswitch_v3.gif" alt="drawing" style="width: 600px;"/>

1. You can also supply the desired version as an argument on the command line.
2. For example, `tgswitch 0.10.7` for version 0.10.7 of terragrunt.
3. Hit **Enter** to switch version.
2. For example, `tgswitch 0.37.1` for version 0.37.1 of terragrunt.
3. Hit **Enter** to switch.

### Use environment variables
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/tgswitch_v7.gif" alt="drawing" style="width: 600px;"/>
You can also set the `TG_VERSION` environment variable to your desired terragrunt version.
For example:
```bash
export TG_VERSION=0.37.0
tgswitch #will automatically switch to terragrunt version 0.37.0
```

### Use custom installation location (For non-admin - users with limited privilege on their computers)
You can specify a custom binary path for your terragrunt installation
### Use .tgswitch.toml file (For non-admin AND Apple M1 users with limited privilege on their computers)
Specify a custom binary path for your terragrunt installation

<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/tgswitch_v5.gif" alt="drawing" style="width: 600px;"/>
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/tgswitch_v4.gif" alt="drawing" style="width: 600px;"/>

1. Create a custom binary path. Ex: `mkdir /Users/uveerum/bin` (replace uveerum with your username)
2. Add the path to your PATH. Ex: `export PATH=$PATH:/Users/uveerum/bin` (add this to your bash profile or zsh profile)
3. Pass -b or --bin parameter with your custom path to install terragrunt. Ex: `tgswitch -b /Users/uveerum/bin/terragrunt 0.34.0 `
4. Optionally, you can create a `.tgswitch.toml` file in your terragrunt directory(current directory) OR in your home directory(~/.tgswitch.toml). The toml file in the current directory has a higher precedence than toml file in the home directory
5. Your `.tgswitch.toml` file should look like this:
```ruby
bin = "/usr/local/bin/terragrunt"
version = "0.34.0"
```
4. Run `tgswitch` and it should automatically install the required terragrunt version in the specified binary path

1. Create a custom binary path. Ex: `mkdir /Users/warrenveerasingam/bin` (replace warrenveerasingam with your username)
2. Add the path to your PATH. Ex: `export PATH=$PATH:/Users/warrenveerasingam/bin` (add this to your bash profile or zsh profile)
3. Pass -b or --bin parameter with your custom path to install terragrunt. Ex: `tgswitch -b /Users/warrenveerasingam/bin/terragrunt 0.14.1 `
**NOTE**
1. For linux users that do not have write permission to `/usr/local/bin/`, `tgswitch` will attempt to install terragrunt at `$HOME/bin`. Run `export PATH=$PATH:$HOME/bin` to append bin to PATH
2. For windows host, `tgswitch` need to be run under `Administrator` mode, and `$HOME/.tgswitch.toml` with `bin` must be defined (with a valid path) as minimum, below is an example for `$HOME/.tgswitch.toml` on windows

```toml
bin = "C:\\Users\\<%USRNAME%>\\bin\\terragrunt.exe"
```
### Use .tgswitchrc file
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/manual-tgswitchrc.gif" alt="drawing" style="width: 170px;"/>
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/tgswitch_v6.gif" alt="drawing" style="width: 600px;"/>

1. Create a `.tgswitchrc` file containing the desired version
2. For example, `echo "0.14.1" >> .tgswitchrc` for version 0.14.1 of terragrunt
2. For example, `echo "0.33.0" >> .tgswitchrc` for version 0.33.0 of terragrunt
3. Run the command `tgswitch` in the same directory as your `.tgswitchrc`

#### *Instead of a `.tgswitchrc` file, a `.terragrunt-version` file may be used for compatibility with [`tgenv`](https://github.com/cunymatthieu/tgenv#terragrunt-version) and other tools which use it*
*Instead of a `.tgswitchrc` file, a `.terragrunt-version` file may be used as well*

### Use terragrunt.hcl file
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/tgswitch_v2.gif" alt="drawing" style="width: 600px;"/>

If a terragrunt.hcl file with the terragrunt constrain is included in the current directory, it should automatically download or switch to that terragrunt version. For example, the following should automatically switch terragrunt to version 0.36.0:
```ruby
terragrunt_version_constraint = ">= 0.36, < 0.36.1"
...
```

### Get the version from a subdirectory
```bash
tgswitch --chdir terragrunt_dir
tgswitch -c terragrunt_dir
```

**Automatically switch with bash**

Add the following to the end of your `~/.bashrc` file:
(Use either `.tgswitchrc` or `.terragrunt-version`)
(Use either `.tgswitchrc` or `.tgswitch.toml` or `.terragrunt-version`)

```
```sh
cdtgswitch(){
builtin cd "$@";
cdir=$PWD;
if [ -f "$cdir/.tgswitchrc" ]; then
if [ -e "$cdir/.tgswitchrc" ]; then
tgswitch
fi
}
alias cd='cdtgswitch'
```

<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/auto-tgswitchrc.gif" alt="drawing" style="width: 170px;"/>

**Automatically switch with zsh**

Add the following to the end of your `~/.zshrc` file:

```
```sh
load-tgswitch() {
local tgswitchrc_path=".tgswitchrc"

Expand All @@ -115,40 +148,17 @@ load-tgswitch
> ```
*older version of zsh*
```
```sh
cd(){
builtin cd "$@";
cdir=$PWD;
if [ -f "$cdir/.tgswitchrc" ]; then
if [ -e "$cdir/.tgswitchrc" ]; then
tgswitch
fi
}
```
**Automatically switch with fish**
Add the following to your `~/.config/fish/config.fish` file:
```
function cdtgswitch
builtin cd "$argv"
set cdir $PWD
if test -f "$cdir/.tgswitchrc"
tgswitch
end
end
alias cd='cdtgswitch'
```
## Additional Info
See how to *upgrade*, *uninstall*, *troubleshoot* here:[More info](https://warrensbox.github.io/tgswitch/additional)
## Issues
Please open *issues* here: [New Issue](https://github.com/warrensbox/tgswitch/issues)

## Upcoming Features
Use environment variable to change terragrunt version
N/A

0 comments on commit 87fc4a7

Please sign in to comment.