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 89f78817a..47c6fce5f 100755 --- a/install.sh +++ b/install.sh @@ -27,7 +27,15 @@ initOS() { case "$OS" in # Minimalist GNU for Windows - mingw*) OS='windows';; + 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 } @@ -107,6 +115,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