├── .github ├── CODEOWNERS └── workflows │ └── workflow.yml ├── bin ├── list-all └── install ├── LICENSE └── README.md /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @asdf-community/asdf-gleam 2 | -------------------------------------------------------------------------------- /bin/list-all: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | git ls-remote --tags --refs https://github.com/gleam-lang/gleam | # get refs and tags 3 | grep -E "nightly|v*" | # check for tags that specify versions, and include the nightly release 4 | sed 's;^.*refs/tags/v*\(.*\)$;\1;' | # clean tag info to only include version number 5 | grep -vE '^(0.1.0|0.1.1|0.1.2)$' | # exclude versions that do not have associated binaries 6 | sort -V | # sort by version number 7 | xargs echo # print version number 8 | -------------------------------------------------------------------------------- /.github/workflows/workflow.yml: -------------------------------------------------------------------------------- 1 | name: Main workflow 2 | 3 | on: 4 | pull_request: 5 | push: 6 | schedule: 7 | - cron: 0 0 * * 5 8 | 9 | jobs: 10 | plugin_test: 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | os: 15 | - macos-latest 16 | - ubuntu-latest 17 | 18 | runs-on: ${{ matrix.os }} 19 | 20 | steps: 21 | - name: asdf_plugin_test 22 | uses: asdf-vm/actions/plugin-test@v1 23 | with: 24 | command: gleam --version 25 | 26 | - name: asdf_plugin_test nightly 27 | uses: asdf-vm/actions/plugin-test@v1 28 | with: 29 | command: gleam --version 30 | version: nightly 31 | 32 | format: 33 | runs-on: macos-latest 34 | 35 | steps: 36 | - name: Checkout code 37 | uses: actions/checkout@v3 38 | 39 | - name: Install shfmt 40 | run: brew install shfmt 41 | 42 | - name: Run shfmt 43 | run: shfmt -d -i 2 -ci . 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 asdf version manager 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # asdf-gleam 2 | 3 | [Gleam](https://github.com/gleam-lang/gleam) plugin for 4 | [asdf](https://github.com/asdf-vm/asdf) version manager 5 | 6 | ## Build History 7 | 8 | [![Build history](https://buildstats.info/github/chart/asdf-community/asdf-gleam?branch=master)](https://github.com/asdf-community/asdf-gleam/actions) 9 | 10 | ## Install 11 | 12 | > \*Gleam runtime depends on Erlang. You might need to install it using 13 | > asdf-erlang. For using gleam libraries you might also need `rebar3`. It is 14 | > installable via asdf-rebar. 15 | 16 | 17 | ``` 18 | asdf plugin-add gleam 19 | ``` 20 | 21 | or 22 | 23 | ``` 24 | asdf plugin-add gleam https://github.com/asdf-community/asdf-gleam.git 25 | ``` 26 | 27 | Since `0.2.0`, Gleam has binary releases for macos and linux. 28 | 29 | ``` 30 | # To install a binary release, just specify it 31 | asdf install gleam latest 32 | ``` 33 | 34 | If you want to build from source. Use 35 | 36 | ```shell 37 | # Installing from source needs Rust. You might want to install it using asdf-rust. 38 | # Using `ref:`, you can specify any branch, tag (like `v0.2.0`) or commit-sha 39 | asdf install gleam ref:main 40 | ``` 41 | 42 | ## Use 43 | 44 | Check [asdf](https://github.com/asdf-vm/asdf) readme for instructions on how to 45 | install & manage versions of Gleam. 46 | -------------------------------------------------------------------------------- /bin/install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -o pipefail 5 | 6 | install_gleam() { 7 | local install_type="$1" 8 | local version="$2" 9 | local install_path="$3" 10 | 11 | if [ "$install_type" = "version" ] && ! (has_binary_release $version); then 12 | echo "ERROR: Gleam version $version has no binary release." 13 | echo "Try installing from source. You will need a working rust compiler." 14 | exit 1 15 | fi 16 | 17 | local tmp_dir=$(mktemp -d -t gleam_build_XXXXXX) 18 | 19 | ( 20 | if test "$install_type" = "version"; then 21 | local release_file="$tmp_dir/gleam-$install_type-$version.tar.gz" 22 | local release_url=$(get_download_url $version) 23 | download_file "$release_file" "$release_url" 24 | mkdir -p $install_path/bin 25 | tar -xf "$release_file" -C $install_path/bin 26 | else 27 | # install from source 28 | git clone --depth 1 --branch "$version" "https://github.com/gleam-lang/gleam" "$tmp_dir/src" 29 | cargo install --path "$tmp_dir/src/compiler-cli" --root "$install_path" 30 | fi 31 | ) || rm -rf $install_path 32 | 33 | rm -rf $tmp_dir 34 | } 35 | 36 | has_binary_release() { 37 | local version="$1" 38 | version_gt "$version" "0.1" 39 | } 40 | 41 | uses_llvm_triplets() { 42 | local version="$1" 43 | test "$version" = "nightly" || version_gt "$version" "0.22.1" 44 | } 45 | 46 | # from https://stackoverflow.com/questions/16989598/bash-comparing-version-numbers/24067243 47 | version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; } 48 | 49 | get_variant() { 50 | local version="$1" 51 | if uses_llvm_triplets "$version"; then 52 | get_llvm_triplet_variant "$version" 53 | else 54 | get_legacy_variant "$version" 55 | fi 56 | } 57 | 58 | get_llvm_triplet_variant() { 59 | local version="$1" 60 | case "$(uname -s)" in 61 | Linux) 62 | case "$(uname -m)" in 63 | x86_64) echo x86_64-unknown-linux-musl ;; 64 | aarch64 | arm64) echo aarch64-unknown-linux-musl ;; 65 | *) fail "$(uname -m) is not supported on linux" ;; 66 | esac 67 | ;; 68 | Darwin) 69 | case "$(uname -m)" in 70 | x86_64) echo x86_64-apple-darwin ;; 71 | arm64) echo aarch64-apple-darwin ;; 72 | *) fail "$(uname -m) is not supported on macos" ;; 73 | esac 74 | ;; 75 | *) fail "$(uname -s) is not supported" ;; 76 | esac 77 | } 78 | 79 | get_legacy_variant() { 80 | local version="$1" 81 | case "$(uname -s)" in 82 | Linux) 83 | case "$(uname -m)" in 84 | x86_64) echo linux-amd64 ;; 85 | *) fail "$(uname -m) is not supported on linux" ;; 86 | esac 87 | ;; 88 | Darwin) 89 | case "$(uname -m)" in 90 | x86_64) echo macos ;; 91 | arm64) echo macos-arm64 ;; 92 | *) fail "$(uname -m) is not supported on macos" ;; 93 | esac 94 | ;; 95 | *) fail "$(uname -s) is not supported" ;; 96 | esac 97 | } 98 | 99 | download_file() { 100 | local download_path="$1" 101 | local download_url="$2" 102 | if test "302" != $(curl -qsI -o /dev/null -w "%{http_code}" "$download_url"); then 103 | echo "Could not find archive at URL $download_url" 104 | exit 2 105 | fi 106 | curl -Lo "$download_path" "$download_url" 107 | } 108 | 109 | get_download_url() { 110 | local version=$1 111 | local variant=$(get_variant $version) 112 | case $version in 113 | nightly) 114 | echo "https://github.com/gleam-lang/gleam/releases/download/nightly/gleam-nightly-${variant}.tar.gz" 115 | ;; 116 | *) 117 | echo "https://github.com/gleam-lang/gleam/releases/download/v${version}/gleam-v${version}-${variant}.tar.gz" 118 | ;; 119 | esac 120 | } 121 | 122 | install_gleam $ASDF_INSTALL_TYPE $ASDF_INSTALL_VERSION $ASDF_INSTALL_PATH 123 | --------------------------------------------------------------------------------