Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/latest version #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

[Zig](https://ziglang.org) plugin for asdf version manager

## Build History

[![Build history](https://buildstats.info/github/chart/asdf-community/asdf-zig?branch=master)](https://github.com/asdf-community/asdf-zig/actions)

## Installation

```bash
asdf plugin-add zig https://github.com/asdf-community/asdf-zig.git
asdf plugin-add zig https://github.com/zigcc/asdf-zig.git
```

## Usage
Expand Down
21 changes: 18 additions & 3 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ install_zig() {
esac

local json
json=$(curl --fail --silent --location https://ziglang.org/download/index.json)
json=$(curl --fail --progress-bar --location https://ziglang.org/download/index.json)

local download_url
download_url=$(
Expand All @@ -60,15 +60,30 @@ install_zig() {
awk 'NR==1 { print $2 }' |
tr -d '"'
)
local expected_shasum
expected_shasum=$(
json_parse "$json" |
grep "\[\"$version\",\"${architecture}-${platform}\",\"shasum\"\]" |
awk '{print $2}' |
tr -d '"'
)

local source_path="${install_path}/zig-${platform}-${architecture}-${version}.tar.xz"

echo "∗ Downloading and installing Zig..."
curl --fail --silent --location --create-dirs --output "$source_path" "$download_url"
curl --fail --progress-bar --location --create-dirs --output "$source_path" "$download_url"

local actual_shasum
actual_shasum="$(shasum -a 256 "$source_path" | awk '{print $1}')"

if [ "${expected_shasum}" != "${actual_shasum}" ]; then
fail "Checksum not same, expected: ${expected_shasum}, actual: ${actual_shasum}, file: ${source_path}"
fi

tar -xf "$source_path" -C "$install_path" --strip-components=1
mkdir -p "${install_path}/bin"
ln -s "${install_path}/zig" "${install_path}/bin/zig"
echo "The installation was successful!"
echo "${version} was installed successful!"
}

install_zig "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"
2 changes: 1 addition & 1 deletion bin/list-all
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -Eo pipefail
# shellcheck disable=SC1091
source "$(dirname "$0")/../lib/json.bash"

json=$(curl --fail --silent --location https://ziglang.org/download/index.json)
json=$(curl --fail --progress-bar --location https://ziglang.org/download/index.json)

sort_versions() {
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' |
Expand Down
Loading