From 5364d93d5f76e86f0cb22bbe5e863426b6da0f65 Mon Sep 17 00:00:00 2001 From: Dominic Letz Date: Thu, 15 Dec 2022 11:58:06 +0100 Subject: [PATCH 1/5] Add support for msys2 on windows --- bin/download | 12 ++++++++---- bin/install | 8 ++++++-- lib/helpers.sh | 4 ++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bin/download b/bin/download index 81d4930..93b45d4 100755 --- a/bin/download +++ b/bin/download @@ -31,21 +31,25 @@ download_golang () { local download_path=$2 local platform="" local arch="" + local filetype="tar.gz" platform=$(get_platform) + if [ "$platform" == "windows" ]; then + filetype="zip" + fi arch=$(get_arch) - download_url="https://dl.google.com/go/go${version}.${platform}-${arch}.tar.gz" + download_url="https://dl.google.com/go/go${version}.${platform}-${arch}.${filetype}" http_code=$(curl -I -w '%{http_code}' -s -o /dev/null "$download_url") if [ "$http_code" -eq 404 ] || [ "$http_code" -eq 403 ]; then fail "URL: ${download_url} returned status ${http_code}" fi - curl "$download_url" -o "${download_path}/archive.tar.gz" - curl "${download_url}.sha256" -o "${download_path}/archive.tar.gz.sha256" + curl "$download_url" -o "${download_path}/archive.${filetype}" + curl "${download_url}.sha256" -o "${download_path}/archive.${filetype}.sha256" echo 'verifying checksum' - if ! check_shasum "${download_path}/archive.tar.gz" "${download_path}/archive.tar.gz.sha256"; then + if ! check_shasum "${download_path}/archive.${filetype}" "${download_path}/archive.${filetype}.sha256"; then fail "Authenticity of package archive can not be assured. Exiting." else msg "checksum verified" diff --git a/bin/install b/bin/install index 2f3ad54..5064361 100755 --- a/bin/install +++ b/bin/install @@ -18,8 +18,12 @@ install_golang () { created_tmp="1" ASDF_INSTALL_VERSION="$version" ASDF_DOWNLOAD_PATH="$download_path" "$PLUGIN_DIR/bin/download" fi - - tar -C "$install_path" -xzf "${download_path}/archive.tar.gz" + + if [ "$(get_platform)" == "windows" ]; then + unzip -d "$install_path" "${download_path}/archive.zip" + else + tar -C "$install_path" -xzf "${download_path}/archive.tar.gz" + fi if [ "1" = "$created_tmp" ]; then rm -r "$download_path" diff --git a/lib/helpers.sh b/lib/helpers.sh index 9fdd109..f1b289c 100644 --- a/lib/helpers.sh +++ b/lib/helpers.sh @@ -9,6 +9,10 @@ get_platform () { platform="$(uname | tr '[:upper:]' '[:lower:]')" case "$platform" in + msys_nt*) + platform="windows" + [ -z "$silent" ] && msg "Platform '${platform}' supported!" + ;; linux|darwin|freebsd) [ -z "$silent" ] && msg "Platform '${platform}' supported!" ;; From 9f6dae1f74239e4dfe871e91b5e2b6297b4947ea Mon Sep 17 00:00:00 2001 From: Dominic Letz Date: Mon, 19 Dec 2022 09:17:33 +0100 Subject: [PATCH 2/5] Added windows --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 24d2f14..aeb3130 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,7 @@ jobs: os: - macos-latest - ubuntu-latest + - windows-latest runs-on: ${{ matrix.os }} From 2243b0352d1d4af22489984da6aa7a7d55577acf Mon Sep 17 00:00:00 2001 From: Dominic Letz Date: Mon, 19 Dec 2022 11:52:37 +0100 Subject: [PATCH 3/5] fixup! --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aeb3130..2d3e433 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,10 @@ jobs: runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash + steps: - name: Test plugin uses: asdf-vm/actions/plugin-test@v1 From 36a87e500173b82124c235701dac0f5e87d66ad5 Mon Sep 17 00:00:00 2001 From: Dominic Letz Date: Mon, 19 Dec 2022 12:00:01 +0100 Subject: [PATCH 4/5] fixup! --- .github/workflows/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2d3e433..818dcd6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,9 +22,13 @@ jobs: defaults: run: - shell: bash + shell: msys2 {0} steps: + - if: runner.os == 'Windows' + name: "Install mingw deps" + uses: msys2/setup-msys2@v2 + - name: Test plugin uses: asdf-vm/actions/plugin-test@v1 with: From 38b378004ad5b18d5b831212e2082947933a44ed Mon Sep 17 00:00:00 2001 From: Dominic Letz Date: Mon, 19 Dec 2022 12:12:30 +0100 Subject: [PATCH 5/5] revert! --- .github/workflows/main.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 818dcd6..24d2f14 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,19 +16,10 @@ jobs: os: - macos-latest - ubuntu-latest - - windows-latest runs-on: ${{ matrix.os }} - defaults: - run: - shell: msys2 {0} - steps: - - if: runner.os == 'Windows' - name: "Install mingw deps" - uses: msys2/setup-msys2@v2 - - name: Test plugin uses: asdf-vm/actions/plugin-test@v1 with: