Skip to content

Commit

Permalink
GitHub Action to install TGF
Browse files Browse the repository at this point in the history
  • Loading branch information
jonapich committed Jul 15, 2024
1 parent 307c4ee commit 89368d7
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
jobs:
posix:
strategy:
fail-fast: false
matrix:
os: [ macos-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
Expand All @@ -17,9 +18,26 @@ jobs:
- uses: actions/checkout@v4
- run: ./get-latest-tgf.sh


windows:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- run: ./get-latest-tgf.ps1


action:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- uses: ./
with:
ref: ${{ github.head_ref }}

- run: tgf --help-tgf
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ outdated version.

## Installation

### GitHub Action

You can install `TGF` using the provided GitHub Action:

```
steps:
- uses: coveooss/tgf@master
```

### Manual installation

On `mac` and `linux`:

You can run the `get-latest-tgf.sh` script to check if you have the latest version of tgf installed and install it as needed:
Expand Down
34 changes: 34 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Install TGF
description: GitHub Action to install https://github.com/coveooss/tgf

inputs:
tgf-path:
description: |
Installs the TGF binary to this folder.
The folder will not be added to the PATH, but the defaults are typically already in the path.
required: false
default: ${{ runner.os == 'Windows' && '${env:LocalAppData}\Microsoft\WindowsApps' || '/usr/local/bin' }}
ref:
description: The ref to use to run the install script.
default: ${{ github.action_ref }}
required: false


runs:
using: "composite"
steps:
- name: Install TGF (posix)
if: runner.os != 'Windows'
shell: bash
env:
TGF_PATH: ${{ inputs.tgf-path }}
VERSION: ${{ inputs.ref }}
run: curl "https://raw.githubusercontent.com/coveooss/tgf/${VERSION}/get-latest-tgf.sh" | bash

- name: Install TGF (windows)
if: runner.os == 'Windows'
shell: pwsh
env:
TGF_PATH: ${{ inputs.tgf-path }}
VERSION: ${{ inputs.ref }}
run: (Invoke-WebRequest https://raw.githubusercontent.com/coveooss/tgf/${env:VERSION}/get-latest-tgf.ps1).Content | Invoke-Expression
8 changes: 6 additions & 2 deletions get-latest-tgf.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ $ZipFile = "tgf.zip"
$TempTgfFolder = "tgf_unzipped"
$TempTgfPath = Join-Path -Path $TempTgfFolder -ChildPath "tgf.exe"

Write-Host "Installing tgf v$($LATEST_VERSION) in the current directory ($(Get-Location)) ..."
Write-Host "Installing: tgf v$($LATEST_VERSION)"
Invoke-WebRequest "https://github.com/coveo/tgf/releases/download/v$($LATEST_VERSION)/tgf_$($LATEST_VERSION)_windows_64-bits.zip" -OutFile $ZipFile
Expand-Archive -Path $ZipFile -DestinationPath $TempTgfFolder
Copy-Item $TempTgfPath -Destination $TGF_PATH -Force

$Destination = if ([string]::IsNullOrWhiteSpace(${env:TGF_PATH})) { "." } else { $ExecutionContext.InvokeCommand.ExpandString(${env:TGF_PATH}) }
Write-Host "Copying executable to $($Destination)"
Copy-Item $TempTgfPath -Destination $Destination -Force

Write-Host "Cleaning up..."
Remove-Item $ZipFile
Remove-Item $TempTgfFolder -Recurse
Write-Host "Installation is completed!"
Expand Down

0 comments on commit 89368d7

Please sign in to comment.