|
| 1 | +name: 'Setup goose' |
| 2 | +description: 'Install and authorize goose' |
| 3 | +branding: |
| 4 | + icon: box |
| 5 | + color: green |
| 6 | +inputs: |
| 7 | + version: |
| 8 | + description: 'Version of goose to install (tip, latest-release, v0.14.1, etc.)' |
| 9 | + required: true |
| 10 | + default: 'latest-release' |
| 11 | +runs: |
| 12 | + using: "composite" |
| 13 | + steps: |
| 14 | + - shell: bash |
| 15 | + run: | |
| 16 | + set -ex |
| 17 | +
|
| 18 | + # Install goose: |
| 19 | + # - if version is "tip", install from tip of main. |
| 20 | + # - if version is "latest-release", look up latest release. |
| 21 | + # - otherwise, install the specified version. |
| 22 | + case ${{ inputs.version }} in |
| 23 | + tip) |
| 24 | + echo "Installing goose using go install" |
| 25 | + go install github.com/pressly/goose/v3/cmd/goose@latest |
| 26 | + ;; |
| 27 | + latest-release) |
| 28 | + tag=$(curl -L -s -u "username:${{ github.token }}" https://api.github.com/pressly/goose/releases/latest | jq -r '.tag_name') |
| 29 | + ;; |
| 30 | + *) |
| 31 | + tag="${{ inputs.version }}" |
| 32 | + esac |
| 33 | +
|
| 34 | + os=${{ runner.os }} |
| 35 | + if [[ $os == "macOS" ]]; then |
| 36 | + os="darwin" |
| 37 | + fi |
| 38 | + if [[ $os == "Windows" ]]; then |
| 39 | + os="windows" |
| 40 | + fi |
| 41 | + if [[ $os == "LINUX" ]]; then |
| 42 | + os="linux" |
| 43 | + fi |
| 44 | +
|
| 45 | + arch=${{ runner.architecture }} |
| 46 | + if [[ $arch == "X64" ]]; then |
| 47 | + arch="x86_64" |
| 48 | + fi |
| 49 | + if [[ $arch == "ARM64" ]]; then |
| 50 | + arch="arm64" |
| 51 | + fi |
| 52 | + if [[ $arch == "X86" ]]; then |
| 53 | + echo "X86 architecture is not supported" |
| 54 | + exit 1 |
| 55 | + fi |
| 56 | + if [[ $arch == "ARM" ]]; then |
| 57 | + echo "ARM architecture is not supported" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | +
|
| 61 | + |
| 62 | +
|
| 63 | + if [[ ! -z ${tag} ]]; then |
| 64 | + echo "Installing goose @ ${tag} for ${os}" |
| 65 | + if [[ $os == "windows" ]]; then |
| 66 | + powershell -Command "Invoke-WebRequest -Uri https://github.com/pressly/goose/releases/download/${tag}/goose_${os}_${arch}.exe -OutFile C:\goose\goose.exe" |
| 67 | + else |
| 68 | + curl -fsL https://github.com/pressly/goose/releases/download/${tag}/goose_${os}_${arch} > /usr/local/bin/goose |
| 69 | + fi |
| 70 | + fi |
0 commit comments