Skip to content

Commit

Permalink
fix: support versions >=1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joke committed Feb 19, 2022
1 parent 3bced42 commit 004a9a3
Show file tree
Hide file tree
Showing 17 changed files with 298 additions and 87 deletions.
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve
title: ""
labels: bug
assignees: ""
---

**Describe the bug**

<!-- A clear and concise description of what the bug is. -->

**Steps to reproduce**

<!-- Steps to reproduce the behavior: -->

**Expected behavior**

<!-- A clear and concise description of what you expected to happen. -->

**Screenshots**

<!-- If applicable, add screenshots to help explain your problem. -->

**Additional context**

<!-- Add any other context about the problem here. -->
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: ""
labels: enhancement
assignees: ""
---

**Is your feature request related to a problem? Please describe.**

<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Describe the solution you'd like**

<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**

<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**

<!-- Add any other context or screenshots about the feature request here. -->
34 changes: 34 additions & 0 deletions .github/PULL_REQUEST/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Usage examples

<!--- Provide examples of intended usage -->

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
8 changes: 4 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: build

on:
push:
branches:
- master
pull_request:

jobs:
plugin_test:
name: asdf plugin test
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: test latest version
uses: asdf-vm/actions/plugin-test@v1
with:
command: kn version
- name: test versions <= 1.0.0
uses: asdf-vm/actions/plugin-test@v1
with:
version: 0.26.0
command: kn version
35 changes: 35 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Lint

on:
push:
branches:
- main
pull_request:

jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install asdf dependencies
uses: asdf-vm/actions/install@v1

- name: Run ShellCheck
run: scripts/shellcheck.bash

shellfmt:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install asdf dependencies
uses: asdf-vm/actions/install@v1

- name: List file to shfmt
run: shfmt -f .

- name: Run shfmt
run: scripts/shfmt.bash
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Release
name: release

on:
push:
branches:
- main
- master

jobs:
release-please:
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shellcheck 0.8.0
shfmt 3.4.2
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ asdf plugin-add kn https://github.com/joke/asdf-kn.git
## Use

Check [asdf](https://github.com/asdf-vm/asdf) readme for instructions on how to install & manage versions of Knative Client

17 changes: 17 additions & 0 deletions bin/download
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

set -euo pipefail

current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")

# shellcheck source=../lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

mkdir -p "$ASDF_DOWNLOAD_PATH"

release_file="$ASDF_DOWNLOAD_PATH/$TOOL_NAME"

download_release "$ASDF_INSTALL_VERSION" "$release_file"

chmod +x "$release_file"
47 changes: 6 additions & 41 deletions bin/install
Original file line number Diff line number Diff line change
@@ -1,46 +1,11 @@
#!/usr/bin/env bash

set -eo pipefail
set -euo pipefail

ASDF_INSTALL_TYPE=${ASDF_INSTALL_TYPE:-version }
[ -n "$ASDF_INSTALL_VERSION" ] || (>&2 echo 'Missing ASDF_INSTALL_VERSION' && exit 1)
[ -n "$ASDF_INSTALL_PATH" ] || (>&2 echo 'Missing ASDF_INSTALL_PATH' && exit 1)
current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")

install_kn() {
local install_type=$1
local version=$2
local install_path=$3
local bin_install_path="$install_path/bin"
local bin_path="${bin_install_path}/kn"
local download_url="$(get_download_url $version)"
# shellcheck source=../lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

mkdir -p "${bin_install_path}"

echo "Downloading kn from ${download_url}"
echo "bin_install_path: ${bin_install_path}"
curl -fL "$download_url" -o "${bin_path}"
chmod +x "${bin_path}"
}

get_download_url() {
case $(uname -s) in
Darwin) os="darwin" ;;
*) os="linux" ;;
esac

case $(uname -m) in
x86_64) arch="amd64" ;;
ppc64le) arch="ppc64le" ;;
s390|s390x) arch="s390x" ;;
aarch64|aarch64_be|armv8b|armv8l) arch="arm64" ;;
*)
echo "Arch '$(uname -m)' not supported!" >&2
exit 1
;;
esac

local version="$1"
echo "https://github.com/knative/client/releases/download/v${version}/kn-${os}-${arch}"
}

install_kn $ASDF_INSTALL_TYPE $ASDF_INSTALL_VERSION $ASDF_INSTALL_PATH
install_version "$ASDF_INSTALL_TYPE" "$ASDF_INSTALL_VERSION" "$ASDF_INSTALL_PATH"
22 changes: 6 additions & 16 deletions bin/list-all
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
#!/usr/bin/env bash

set -eo pipefail
set -euo pipefail

cmd="curl --silent --location"
releases_path="https://api.github.com/repos/knative/client/releases"
current_script_path=${BASH_SOURCE[0]}
plugin_dir=$(dirname "$(dirname "$current_script_path")")

if [ -n "$GITHUB_API_TOKEN" ]; then
cmd="$cmd --header 'Authorization: token $GITHUB_API_TOKEN'"
fi
# shellcheck source=../lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

sort_versions() {
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' |
LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}'
}

filter_unsupported() {
grep -Ev '[^.]+\.([0-9]|1[0-5])\.'
}

eval "$cmd $releases_path" | grep 'tag_name' | sed -e 's/.* "//;s/",//' | sed -e 's/^v\(.*\)/\1/' | filter_unsupported | sort_versions | xargs
list_all_versions | sort_versions | xargs echo
12 changes: 12 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Contributing

Testing Locally:

```shell
asdf plugin test <plugin-name> <plugin-url> [--asdf-tool-version <version>] [--asdf-plugin-gitref <git-ref>] [test-command*]

#
asdf plugin test <YOUR TOOL> https://github.com/<YOUR GITHUB USERNAME>/asdf-<YOUR TOOL>.git "<TOOL CHECK>"
```

Tests are automatically run in GitHub Actions on push and PR.
Loading

0 comments on commit 004a9a3

Please sign in to comment.