Skip to content

Commit

Permalink
Merge pull request #1 from signavio/update-repo
Browse files Browse the repository at this point in the history
feat: add go-task
  • Loading branch information
karlderkaefer authored Apr 8, 2022
2 parents dea7aee + 08174c3 commit 23506db
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ jobs:
- name: asdf_plugin_test
uses: asdf-vm/actions/plugin-test@v1
with:
command: xterrafile version
command: task --version
github_token: ${{ secrets.GITHUB_TOKEN }}
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div align="center">

# asdf-xterrafile [![Build](https://github.com/signavio/asdf-xterrafile/actions/workflows/build.yml/badge.svg)](https://github.com/signavio/asdf-xterrafile/actions/workflows/build.yml) [![Lint](https://github.com/signavio/asdf-xterrafile/actions/workflows/lint.yml/badge.svg)](https://github.com/signavio/asdf-xterrafile/actions/workflows/lint.yml)
# asdf-task [![Build](https://github.com/signavio/asdf-task/actions/workflows/build.yml/badge.svg)](https://github.com/signavio/asdf-task/actions/workflows/build.yml) [![Lint](https://github.com/signavio/asdf-task/actions/workflows/lint.yml/badge.svg)](https://github.com/signavio/asdf-task/actions/workflows/lint.yml)


[xterrafile](https://github.com/signavio/xterrafile) plugin for the [asdf version manager](https://asdf-vm.com).
[task](https://github.com/go-task/task) plugin for the [asdf version manager](https://asdf-vm.com).

</div>

Expand All @@ -24,25 +24,25 @@
Plugin:

```shell
asdf plugin add xterrafile
asdf plugin add task
# or
asdf plugin add xterrafile https://github.com/signavio/asdf-xterrafile.git
asdf plugin add task https://github.com/signavio/asdf-task.git
```

xterrafile:
task:

```shell
# Show all installable versions
asdf list-all xterrafile
asdf list-all task

# Install specific version
asdf install xterrafile latest
asdf install task latest

# Set a version globally (on your ~/.tool-versions file)
asdf global xterrafile latest
asdf global task latest

# Now xterrafile commands are available
xterrafile --version
# Now task commands are available
task --version
```

Check [asdf](https://github.com/asdf-vm/asdf) readme for more instructions on how to
Expand All @@ -52,11 +52,11 @@ install & manage versions.

Contributions of any kind welcome! See the [contributing guide](contributing.md).

[Thanks goes to these contributors](https://github.com/signavio/asdf-xterrafile/graphs/contributors)!
[Thanks goes to these contributors](https://github.com/signavio/asdf-task/graphs/contributors)!

## Testing
```bash
asdf plugin-test xterrafile https://github.com/signavio/asdf-xterrafile --asdf-tool-version latest --asdf-plugin-gitref $(git rev-parse HEAD) xterrafile --version
asdf plugin-test task https://github.com/signavio/asdf-task --asdf-tool-version latest --asdf-plugin-gitref $(git rev-parse HEAD) task --version
```


Expand Down
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Testing Locally:
asdf plugin test <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [test-command*]

#
asdf plugin test xterrafile https://github.com/signavio/asdf-xterrafile.git "xterrafile --version"
asdf plugin test task https://github.com/signavio/asdf-task.git "task --version"
```

Tests are automatically run in GitHub Actions on push and PR.
28 changes: 17 additions & 11 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

set -euo pipefail

# TODO: Ensure this is the correct GitHub homepage where releases can be downloaded for xterrafile.
GH_REPO="https://github.com/devopsmakers/xterrafile"
TOOL_NAME="xterrafile"
TOOL_TEST="xterrafile version"
# TODO: Ensure this is the correct GitHub homepage where releases can be downloaded for task.
GH_REPO="https://github.com/go-task/task"
TOOL_NAME="task"
TOOL_TEST="task version"

fail() {
echo -e "asdf-$TOOL_NAME: $*"
Expand All @@ -14,7 +14,7 @@ fail() {

curl_opts=(-fsSL)

# NOTE: You might want to remove this if xterrafile is not hosted on GitHub releases.
# NOTE: You might want to remove this if task is not hosted on GitHub releases.
if [ -n "${GITHUB_API_TOKEN:-}" ]; then
curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN")
fi
Expand All @@ -32,24 +32,30 @@ list_github_tags() {

list_all_versions() {
# TODO: Adapt this. By default we simply list the tag names from GitHub releases.
# Change this function if xterrafile has other means of determining installable versions.
# Change this function if task has other means of determining installable versions.
list_github_tags
}

download_release() {
local version filename url platform
local version filename url platform arch

version="$1"
filename="$2"

case $(uname -m) in
x86_64) arch="amd64" ;;
arm64) arch="arm64" ;;
*) arch="$(uname -m)" ;;
esac

platform="$(uname | tr '[:upper:]' '[:lower:]')"
if [[ ! (${platform} == linux || ${platform} == darwin) ]]; then
fail "Unsupported platform '${platform}' found. Only Linux and Darwin are supported."
fi

# TODO: Adapt the release URL convention for xterrafile
# https://github.com/devopsmakers/xterrafile/releases/download/v2.3.1/xterrafile_2.3.1_Darwin_x86_64.tar.gz
url="$GH_REPO/releases/download/v${version}/${TOOL_NAME}_${version}_${platform}_x86_64.tar.gz"
# TODO: Adapt the release URL convention for task
# https://github.com/go-task/task/releases/download/v3.12.0/task_linux_amd64.deb
url="$GH_REPO/releases/download/v${version}/${TOOL_NAME}_${platform}_${arch}.tar.gz"

echo "* Downloading $TOOL_NAME release $version..."
curl "${curl_opts[@]}" -o "$filename" "$url" || fail "Could not download $url"
Expand All @@ -69,7 +75,7 @@ install_version() {
echo "install path"
cp -r "$ASDF_DOWNLOAD_PATH"/* "$install_path"

# TODO: Asert xterrafile executable exists.
# TODO: Asert task executable exists.
local tool_cmd
tool_cmd="$(echo "$TOOL_TEST" | cut -d' ' -f1)"
test -x "$install_path/$tool_cmd" || fail "Expected $install_path/$tool_cmd to be executable."
Expand Down

0 comments on commit 23506db

Please sign in to comment.