-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
set GOPATH=%WORKSPACE% | ||
set MAGEFILE_CACHE=%WORKSPACE%\.magefile | ||
|
||
set PATH=%WORKSPACE%\bin;C:\ProgramData\chocolatey\bin;%PATH% | ||
|
||
curl --version >nul 2>&1 && ( | ||
echo found curl | ||
) || ( | ||
choco install curl -y --no-progress --skipdownloadcache | ||
) | ||
|
||
mkdir %WORKSPACE%\bin | ||
|
||
IF EXIST "%PROGRAMFILES(X86)%" ( | ||
REM Force the gvm installation. | ||
SET GVM_BIN=gvm.exe | ||
curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-windows-amd64.exe | ||
IF ERRORLEVEL 1 ( | ||
REM gvm installation has failed. | ||
del bin\gvm.exe /s /f /q | ||
exit /b 1 | ||
) | ||
) ELSE ( | ||
REM Windows 7 workers got a broken gvm installation. | ||
curl -L -o %WORKSPACE%\bin\gvm.exe https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-windows-386.exe | ||
IF ERRORLEVEL 1 ( | ||
REM gvm installation has failed. | ||
del bin\gvm.exe /s /f /q | ||
exit /b 1 | ||
) | ||
) | ||
|
||
SET GVM_BIN=gvm.exe | ||
WHERE /q %GVM_BIN% | ||
%GVM_BIN% version | ||
|
||
REM Install the given go version | ||
%GVM_BIN% --debug install %GO_VERSION% | ||
|
||
REM Configure the given go version | ||
FOR /f "tokens=*" %%i IN ('"%GVM_BIN%" use %GO_VERSION% --format=batch') DO %%i | ||
|
||
go env | ||
IF ERRORLEVEL 1 ( | ||
REM go is not configured correctly. | ||
rmdir %WORKSPACE%\.gvm /s /q | ||
exit /b 1 | ||
) | ||
|
||
where mage | ||
mage -version | ||
IF ERRORLEVEL 1 ( | ||
go get github.com/magefile/mage | ||
IF ERRORLEVEL 1 ( | ||
exit /b 1 | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
set -exuo pipefail | ||
|
||
MSG="environment variable missing" | ||
GO_VERSION=${GO_VERSION:?$MSG} | ||
PROPERTIES_FILE=${PROPERTIES_FILE:-"go_env.properties"} | ||
HOME=${HOME:?$MSG} | ||
OS=$(uname -s| tr '[:upper:]' '[:lower:]') | ||
ARCH=$(uname -m| tr '[:upper:]' '[:lower:]') | ||
GVM_CMD="${HOME}/bin/gvm" | ||
|
||
if command -v go | ||
then | ||
set +e | ||
echo "Found Go. Checking version.." | ||
FOUND_GO_VERSION=$(go version|awk '{print $3}'|sed s/go//) | ||
if [ "$FOUND_GO_VERSION" == "$GO_VERSION" ] | ||
then | ||
echo "Versions match. No need to install Go. Exiting." | ||
exit 0 | ||
fi | ||
set -e | ||
fi | ||
|
||
if [ "${ARCH}" == "aarch64" ] ; then | ||
GVM_ARCH_SUFFIX=arm64 | ||
elif [ "${ARCH}" == "x86_64" ] ; then | ||
GVM_ARCH_SUFFIX=amd64 | ||
elif [ "${ARCH}" == "i686" ] ; then | ||
GVM_ARCH_SUFFIX=386 | ||
else | ||
GVM_ARCH_SUFFIX=arm | ||
fi | ||
|
||
echo "UNMET DEP: Installing Go" | ||
mkdir -p "${HOME}/bin" | ||
|
||
curl -sSLo "${GVM_CMD}" "https://github.com/andrewkroh/gvm/releases/download/v0.3.0/gvm-${OS}-${GVM_ARCH_SUFFIX}" | ||
chmod +x "${GVM_CMD}" | ||
|
||
${GVM_CMD} "${GO_VERSION}" |cut -d ' ' -f 2|tr -d '\"' > ${PROPERTIES_FILE} | ||
|
||
eval "$("${GVM_CMD}" "${GO_VERSION}")" |