From f2ffed2be3e0725cb51ce41fd8d6c032845029e7 Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 21 May 2025 23:35:35 -0400 Subject: [PATCH 1/6] implementing version checks --- .gitea/workflows/test.yaml | 9 +++------ action.yaml | 2 +- install.sh | 6 ++++++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index 906459d..e80c014 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -2,12 +2,10 @@ name: "test" run-name: "test" on: push: - branches: - - master jobs: test: - runs-on: [smoketest] + runs-on: fire steps: - uses: actions/checkout@v4 @@ -19,9 +17,8 @@ jobs: - name: "run go install script" shell: bash env: - GO_INSTALL_COMMANDS: github.com/jake-young-dev/kelp@v0.0.9 + GO_INSTALL_COMMANDS: code.jakeyoungdev.com/jake/mctl@v0.3.4 GO_INSTALL_ARCH: amd64 - GO_INSTALL_PURGE: no run: | chmod +x install.sh ./install.sh @@ -32,4 +29,4 @@ jobs: - name: "check go installed command" shell: bash - run: kelp -v | grep "kelp version v0.0.9" \ No newline at end of file + run: mctl -v | grep "mctl version v0.3.4" \ No newline at end of file diff --git a/action.yaml b/action.yaml index 0ba21fe..dbe0be6 100644 --- a/action.yaml +++ b/action.yaml @@ -3,7 +3,7 @@ description: "simple and fast install for golang and golang commands on linux wo inputs: arch: description: "Optional, the linux architecture to use when downloading Go files (default: amd64)" - required: true + required: false default: "amd64" purge: description: "Optional, deletes any previously installed go versions (yes|no)" diff --git a/install.sh b/install.sh index 63cf71a..82f985d 100755 --- a/install.sh +++ b/install.sh @@ -37,6 +37,12 @@ if [[ "$GO_CHECK" ]]; then sudo rm -r /usr/bin/gofmt else #TODO1: if installed version matches requested version we can consider the job successful + #go version go1.23.0 linux/amd64 + GVC=$(go version) + if [[ "$GVC" == "go version go${DL_VERSION} linux/${DL_ARCH}" ]]; then + echo "Requested Go version already installed, skipping." + exit 0 + fi echo "FATAL: Go is already installed, set purge to 'yes' if you wish to update installed version" exit 1 fi -- 2.47.2 From 58c8a231e1aec5ae4a45591e456a4f7316aaca1d Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 21 May 2025 23:39:06 -0400 Subject: [PATCH 2/6] [ci] runner update --- .gitea/workflows/test.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index e80c014..6b1e721 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -1,11 +1,10 @@ name: "test" run-name: "test" -on: - push: +on: push jobs: test: - runs-on: fire + runs-on: water steps: - uses: actions/checkout@v4 -- 2.47.2 From d626c5f11013699605b824598bb9caccf2db8bb9 Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 21 May 2025 23:44:28 -0400 Subject: [PATCH 3/6] [ci] runner update --- .gitea/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index 6b1e721..36301a8 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -4,7 +4,7 @@ on: push jobs: test: - runs-on: water + runs-on: action steps: - uses: actions/checkout@v4 -- 2.47.2 From b6d1948c4b001e683da167e873161ba07d7beed7 Mon Sep 17 00:00:00 2001 From: jake Date: Thu, 22 May 2025 19:51:54 -0400 Subject: [PATCH 4/6] script rewrite - skips if version is installed - moved command setup to function --- TODO.txt | 3 --- install.sh | 59 ++++++++++++++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 29 deletions(-) delete mode 100644 TODO.txt diff --git a/TODO.txt b/TODO.txt deleted file mode 100644 index 4f059cd..0000000 --- a/TODO.txt +++ /dev/null @@ -1,3 +0,0 @@ -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 \ No newline at end of file diff --git a/install.sh b/install.sh index 82f985d..20ab819 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,24 @@ #!/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" #validate version and architecture @@ -30,23 +49,24 @@ echo "Checking if go is already installed" # -v writes string that indicates command or command path to output, prevents command not found error GO_CHECK=$(command -v go) if [[ "$GO_CHECK" ]]; then - #if purge flag is set remove old go files - if [[ "$GO_INSTALL_PURGE" == "yes" ]]; then + #if the version of go matches the requested version, skip + GVC=$(go version) + 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" sudo rm -r /usr/bin/go sudo rm -r /usr/bin/gofmt - else - #TODO1: if installed version matches requested version we can consider the job successful - #go version go1.23.0 linux/amd64 - GVC=$(go version) - if [[ "$GVC" == "go version go${DL_VERSION} linux/${DL_ARCH}" ]]; then - echo "Requested Go version already installed, skipping." - exit 0 - fi - echo "FATAL: Go is already installed, set purge to 'yes' if you wish to update installed version" - exit 1 fi fi + echo "Ready for install" echo "Downloading go files for ${DL_VERSION}/${DL_ARCH}" @@ -88,17 +108,4 @@ GP=$(go env GOPATH)/bin export PATH=$PATH:$GP echo "$GP" >> "$GITHUB_PATH" -#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 \ No newline at end of file +installCommands \ No newline at end of file -- 2.47.2 From efcd7484831447441fca0d0925f67a64bada11da Mon Sep 17 00:00:00 2001 From: jake Date: Thu, 22 May 2025 23:58:03 +0000 Subject: [PATCH 5/6] Update .gitea/workflows/test.yaml --- .gitea/workflows/test.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index 36301a8..a81f5f9 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -28,4 +28,13 @@ jobs: - name: "check go installed command" shell: bash - run: mctl -v | grep "mctl version v0.3.4" \ No newline at end of file + run: mctl -v | grep "mctl version v0.3.4" + + - name: "this should skip" + shell: bash + env: + GO_INSTALL_COMMANDS: code.jakeyoungdev.com/jake/mctl@v0.3.4 + GO_INSTALL_ARCH: amd64 + run: | + chmod +x install.sh + ./install.sh \ No newline at end of file -- 2.47.2 From 14d548774bb115d2248b42551f045f5de7d9d4ed Mon Sep 17 00:00:00 2001 From: jake Date: Fri, 23 May 2025 01:30:54 +0000 Subject: [PATCH 6/6] Update .gitea/workflows/test.yaml --- .gitea/workflows/test.yaml | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index a81f5f9..36301a8 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -28,13 +28,4 @@ jobs: - name: "check go installed command" shell: bash - run: mctl -v | grep "mctl version v0.3.4" - - - name: "this should skip" - shell: bash - env: - GO_INSTALL_COMMANDS: code.jakeyoungdev.com/jake/mctl@v0.3.4 - GO_INSTALL_ARCH: amd64 - run: | - chmod +x install.sh - ./install.sh \ No newline at end of file + run: mctl -v | grep "mctl version v0.3.4" \ No newline at end of file -- 2.47.2