Compare commits

..

No commits in common. "main" and "v0.1.2" have entirely different histories.
main ... v0.1.2

5 changed files with 33 additions and 40 deletions

View File

@ -1,10 +1,13 @@
name: "test" name: "test"
run-name: "test" run-name: "test"
on: push on:
push:
branches:
- master
jobs: jobs:
test: test:
runs-on: action runs-on: [smoketest]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -16,8 +19,9 @@ jobs:
- name: "run go install script" - name: "run go install script"
shell: bash shell: bash
env: env:
GO_INSTALL_COMMANDS: code.jakeyoungdev.com/jake/mctl@v0.3.4 GO_INSTALL_COMMANDS: github.com/jake-young-dev/kelp@v0.0.9
GO_INSTALL_ARCH: amd64 GO_INSTALL_ARCH: amd64
GO_INSTALL_PURGE: no
run: | run: |
chmod +x install.sh chmod +x install.sh
./install.sh ./install.sh
@ -28,4 +32,4 @@ jobs:
- name: "check go installed command" - name: "check go installed command"
shell: bash shell: bash
run: mctl -v | grep "mctl version v0.3.4" run: kelp -v | grep "kelp version v0.0.9"

View File

@ -1,5 +1,4 @@
# install-go # install-go
![tests](https://code.jakeyoungdev.com/actions/install-go/actions/workflows/test.yaml/badge.svg?branch=main&event=push) <br />
An extremely simple github action to install golang and golang commands (using "go install") on linux hosts. This provides the ability to install and setup golang without node/typescript which is required when using [actions/setup-go](https://github.com/actions/setup-go). An extremely simple github action to install golang and golang commands (using "go install") on linux hosts. This provides the ability to install and setup golang without node/typescript which is required when using [actions/setup-go](https://github.com/actions/setup-go).
@ -10,7 +9,7 @@ Use a tagged release to avoid unexpected changes that may come to the master bra
uses: https://code.jakeyoungdev.com/actions/install-go@master uses: https://code.jakeyoungdev.com/actions/install-go@master
with: with:
commands: | commands: |
code.jakeyoungdev.com/jake/mctl@v0.3.3 github.com/jake-young-dev/kelp@v0.0.9
``` ```
#### Go verions #### Go verions

3
TODO.txt Normal file
View File

@ -0,0 +1,3 @@
Comments are left in code using TODO# to track possible implementation location.
TODO1. check current installed version to see if it matches requested install version, only error if they don't match

View File

@ -3,7 +3,7 @@ description: "simple and fast install for golang and golang commands on linux wo
inputs: inputs:
arch: arch:
description: "Optional, the linux architecture to use when downloading Go files (default: amd64)" description: "Optional, the linux architecture to use when downloading Go files (default: amd64)"
required: false required: true
default: "amd64" default: "amd64"
purge: purge:
description: "Optional, deletes any previously installed go versions (yes|no)" description: "Optional, deletes any previously installed go versions (yes|no)"

View File

@ -1,24 +1,5 @@
#!/bin/bash #!/bin/bash
#installs any commands set in the command input value
function installCommands {
#if commands input is set pull the input and install them all using 'go install'
if [[ "$GO_INSTALL_COMMANDS" != "." ]]; then # "." is used as a default
#allows for multiple cmds using |
INPUT_ARR=( $GO_INSTALL_COMMANDS )
for i in "${INPUT_ARR[@]}"; do
echo "Installing go command from ${i}"
if go install ${i}; then
echo "Command setup for ${i}"
else
echo "FATAL: Unable to install ${i} with go"
exit 1
fi
done
fi
}
#start script
echo "Starting Golang install" echo "Starting Golang install"
#validate version and architecture #validate version and architecture
@ -49,24 +30,17 @@ echo "Checking if go is already installed"
# -v writes string that indicates command or command path to output, prevents command not found error # -v writes string that indicates command or command path to output, prevents command not found error
GO_CHECK=$(command -v go) GO_CHECK=$(command -v go)
if [[ "$GO_CHECK" ]]; then if [[ "$GO_CHECK" ]]; then
#if the version of go matches the requested version, skip #if purge flag is set remove old go files
GVC=$(go version) if [[ "$GO_INSTALL_PURGE" == "yes" ]]; then
if [[ "$GVC" == "go version go${DL_VERSION} linux/${DL_ARCH}" ]]; then
echo "Go ${DL_VERSION} already installed, skipping!"
installCommands
exit 0
fi
#if the purge flag is not set and version does not match, exit
if [[ "$GO_INSTALL_PURGE" != "yes" ]]; then
echo "FATAL: The wrong version of Go is already installed, set purge to 'yes' if you wish to update installed version"
exit 1
else
echo "Removing old go versions" echo "Removing old go versions"
sudo rm -r /usr/bin/go sudo rm -r /usr/bin/go
sudo rm -r /usr/bin/gofmt sudo rm -r /usr/bin/gofmt
else
#TODO1: if installed version matches requested version we can consider the job successful
echo "FATAL: Go is already installed, set purge to 'yes' if you wish to update installed version"
exit 1
fi fi
fi fi
echo "Ready for install" echo "Ready for install"
echo "Downloading go files for ${DL_VERSION}/${DL_ARCH}" echo "Downloading go files for ${DL_VERSION}/${DL_ARCH}"
@ -108,4 +82,17 @@ GP=$(go env GOPATH)/bin
export PATH=$PATH:$GP export PATH=$PATH:$GP
echo "$GP" >> "$GITHUB_PATH" echo "$GP" >> "$GITHUB_PATH"
installCommands #if commands input is set pull the input and install them all using 'go install'
if [[ "$GO_INSTALL_COMMANDS" != "." ]]; then # "." is used as a default
#allows for multiple cmds using |
INPUT_ARR=( $GO_INSTALL_COMMANDS )
for i in "${INPUT_ARR[@]}"; do
echo "Installing go command from ${i}"
if go install ${i}; then
echo "Command setup for ${i}"
else
echo "FATAL: Unable to install ${i} with go"
exit 1
fi
done
fi