From b90bac4acf47e23995029a21ce3130adb389f4cf Mon Sep 17 00:00:00 2001 From: Hal Deadman Date: Sun, 9 Oct 2022 10:55:18 -0400 Subject: [PATCH 1/2] fix install script on windows --- install.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 89f78817a..e8c067b30 100755 --- a/install.sh +++ b/install.sh @@ -27,7 +27,10 @@ initOS() { case "$OS" in # Minimalist GNU for Windows - mingw*) OS='windows';; + mingw*) + OS="windows" + USE_SUDO="false" + ;; esac } @@ -107,6 +110,9 @@ checkLatestVersion() { downloadFile() { K3D_DIST="k3d-$OS-$ARCH" DOWNLOAD_URL="$REPO_URL/releases/download/$TAG/$K3D_DIST" + if [[ "$OS" == "windows" ]]; then + DOWNLOAD_URL=${DOWNLOAD_URL}.exe + fi K3D_TMP_ROOT="$(mktemp -dt k3d-binary-XXXXXX)" K3D_TMP_FILE="$K3D_TMP_ROOT/$K3D_DIST" if type "curl" > /dev/null; then From 2f3d9ca18d08683966aa6aa2ab34fefd77fc7524 Mon Sep 17 00:00:00 2001 From: hdeadman Date: Sun, 9 Oct 2022 11:17:07 -0400 Subject: [PATCH 2/2] test install.sh script with workflow --- .github/workflows/test-install-osmatrix.yaml | 30 ++++++++++++++++++++ install.sh | 5 ++++ 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/test-install-osmatrix.yaml diff --git a/.github/workflows/test-install-osmatrix.yaml b/.github/workflows/test-install-osmatrix.yaml new file mode 100644 index 000000000..07c3ee3a2 --- /dev/null +++ b/.github/workflows/test-install-osmatrix.yaml @@ -0,0 +1,30 @@ +name: Test install.sh + +on: + pull_request: + paths: + - 'install.sh' + push: + branches: + - 'main' + - 'pr-*' + +jobs: + test-install-script: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Run install.sh on ${{ matrix.os }} + shell: bash + # just run install.sh b/c github can throttle itself based on egress limits and gets 503 sometimes + run: | + echo "Simulating: curl -s https://raw.githubusercontent.com/$GITHUB_REPOSITORY/$GITHUB_REF_NAME/install.sh | bash" + ./install.sh + k3d version + - name: Create cluster + if: matrix.os == 'ubuntu-latest' # mac and windows Github runners can't use docker + run: k3d cluster create demo diff --git a/install.sh b/install.sh index e8c067b30..47c6fce5f 100755 --- a/install.sh +++ b/install.sh @@ -30,6 +30,11 @@ initOS() { mingw*) OS="windows" USE_SUDO="false" + if [[ ! -d "$K3D_INSTALL_DIR" ]]; then + # mingw bash that ships with Git for Windows doesn't have /usr/local/bin but ~/bin is first entry in the path + mkdir -p ~/bin + K3D_INSTALL_DIR=~/bin + fi ;; esac }