Skip to content

Commit 9ddb657

Browse files
authored
feat: bundled installers for all, source installers for v2 (#21)
* bundled installers for all, source installers for v2 * performance improvements (stolen from asdf-vm/asdf-plugin-template#58) * update readme,contributing,funding * workflows: move schedules from daily to weekly, just build on earliest/latest python supported
1 parent c645552 commit 9ddb657

17 files changed

+444
-204
lines changed

Diff for: .github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [MetricMike]

Diff for: .github/dependabot.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# .github/dependabot.yml
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly" # Check for updates to GitHub Actions every week

Diff for: .github/workflows/build.yml

+54-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: Build
2+
23
on:
34
pull_request:
4-
branches:
5-
- main
65
paths-ignore:
76
- "**.md"
87
push:
@@ -11,24 +10,70 @@ on:
1110
paths-ignore:
1211
- "**.md"
1312
schedule:
14-
- cron: "0 0 * * *" # daily at midnight
13+
- cron: "0 0 * * 0" # weekly at midnight on sundays (ish)
14+
15+
env:
16+
ASDF_CONCURRENCY: 2
1517

1618
jobs:
17-
plugin_test:
18-
name: asdf plugin test
19+
build_from_installers:
20+
name: asdf-awscli plugin test using prebuilt installers
1921
strategy:
2022
matrix:
21-
os: [ubuntu-latest, macos-latest]
22-
python-version: ['3.7', '3.8', '3.9', '3.10']
23-
cli-version: ['latest:1', 'latest:2']
23+
os:
24+
- ubuntu-latest
25+
- macos-latest
26+
# - windows-latest In theory this should work, but ASDF requires bash and
27+
python-version:
28+
- "3.8"
29+
- "3.11"
30+
cli-version:
31+
- "latest:1"
32+
- "latest:2"
2433
runs-on: ${{ matrix.os }}
2534
steps:
2635
- name: Set up Python
2736
uses: actions/setup-python@v4
2837
with:
2938
python-version: ${{ matrix.python-version }}
39+
3040
- name: asdf_plugin_test
31-
uses: asdf-vm/actions/plugin-test@v1
41+
uses: asdf-vm/actions/plugin-test@v2
3242
with:
3343
command: aws --version
3444
version: ${{ matrix.cli-version }}
45+
46+
build_from_source:
47+
name: asdf-awscli plugin test using source
48+
strategy:
49+
matrix:
50+
os:
51+
- ubuntu-latest
52+
- macos-latest
53+
python-version:
54+
- "3.8"
55+
- "3.11"
56+
runs-on: ${{ matrix.os }}
57+
steps:
58+
- name: Set up Python
59+
uses: actions/setup-python@v4
60+
with:
61+
python-version: ${{ matrix.python-version }}
62+
63+
- name: Install asdf-awscli
64+
uses: asdf-vm/actions/plugins-add@v2
65+
with:
66+
tool_versions: |
67+
# tools won't be installed by this action, only plugins
68+
awscli
69+
70+
- name: Retrieve latest version
71+
run: |
72+
echo "cli-version=ref:$(asdf latest awscli 2)" >> "${GITHUB_ENV}"
73+
74+
- name: asdf_plugin_test
75+
uses: asdf-vm/actions/plugin-test@v2
76+
with:
77+
skip_install: true
78+
command: aws --version
79+
version: ${{ env.cli-version }}

Diff for: .github/workflows/lint.yml

+13-27
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: Lint
2+
23
on:
34
pull_request:
4-
branches:
5-
- main
65
paths-ignore:
76
- "**.md"
87
push:
@@ -11,34 +10,21 @@ on:
1110
paths-ignore:
1211
- "**.md"
1312
schedule:
14-
- cron: "0 0 * * *" # daily at midnight
13+
- cron: "0 0 * * 0" # weekly at midnight on sundays (ish)
1514

1615
jobs:
17-
shellcheck:
18-
name: shellcheck
16+
lint:
1917
runs-on: ubuntu-latest
2018
steps:
21-
- name: Checkout code
22-
uses: actions/checkout@v2
23-
- name: Update Shellcheck
24-
run: |
25-
sudo apt install xz-utils
26-
scversion="stable"
27-
wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv
28-
sudo cp "shellcheck-${scversion}/shellcheck" /usr/bin/
29-
shellcheck --version
30-
- name: Shellcheck
31-
run: shellcheck -x bin/* -P lib/
32-
33-
shfmt:
34-
runs-on: macos-latest
19+
- uses: actions/checkout@v3
20+
- uses: asdf-vm/actions/install@v2
21+
- run: scripts/lint.bash
3522

23+
actionlint:
24+
runs-on: ubuntu-latest
3625
steps:
37-
- name: Checkout code
38-
uses: actions/checkout@v2
39-
40-
- name: Install shfmt
41-
run: brew install shfmt
42-
43-
- name: Run shfmt
44-
run: shfmt -d -i 2 -ci .
26+
- uses: actions/checkout@v3
27+
- name: Check workflow files
28+
uses: docker://rhysd/actionlint:1.6.23
29+
with:
30+
args: -color

Diff for: .github/workflows/release.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: GoogleCloudPlatform/release-please-action@v3
17+
with:
18+
release-type: simple

Diff for: .github/workflows/semantic-pr.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: SemanticPR
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- synchronize
9+
10+
jobs:
11+
semantic-pr:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: amannn/[email protected]
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
with:
18+
validateSingleCommit: true

Diff for: .tool-versions

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
shellcheck 0.9.0
2+
shfmt 3.6.0

Diff for: LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Michael Weigle
3+
Copyright (c) 2023 Michael Weigle
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Diff for: README.md

+42-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
</div>
88

9+
# Build History
10+
[![Build history](https://buildstats.info/github/chart/MetricMike/asdf-awscli?branch=main)](https://github.com/MetricMike/asdf-awscli/actions)
11+
912
# Contents
1013

1114
- [Dependencies](#dependencies)
@@ -16,10 +19,10 @@
1619
# Dependencies
1720

1821
- `curl`, `git`: Required by [asdf](https://asdf-vm.com/guide/getting-started.html#_1-install-dependencies)
19-
- `bash`, `tar`, `unzip`: generic POSIX utilities. These should be installed by default on most operating systems.
20-
21-
- v1 - Linux/MacOS/Windows || v2 - Windows
22-
- `Python 3+ w/ current support (3.7.13+ as of 20JUN2022)`: For v1 (and v2 on Windows until https://github.com/MetricMike/asdf-awscli/issues/2 is resolved), this plugin installs awscli from source into a virtualenv on these OS distributions utilizing pip. In theory, most Python 3s will be sufficient, but issues will be closed if the Python is not listed as green on https://endoflife.date/python.
22+
- `bash`, `tar`, `unzip`, `coreutils`: generic POSIX utilities. These should be installed by default on most operating systems.
23+
- Python 3.8+ (v1, v2 when building from source) https://aws.amazon.com/blogs/developer/python-support-policy-updates-for-aws-sdks-and-tools/
24+
- `make/autotools` (v2 when building from source)
25+
- `Rosetta 2` (v2 when using the pre-built installers on Apple Silicon)
2326

2427
# Install
2528

@@ -37,18 +40,48 @@ awscli:
3740
# Show all installable versions
3841
asdf list all awscli
3942

40-
# Install specific version
41-
asdf install awscli latest # 2.1.24
42-
asdf install awscli latest:2 # 2.1.24
43-
asdf install awscli latest:1 # 1.19.4
43+
# Install the latest version (optionally with a version prefix)
44+
asdf install awscli latest # 2.11.15
45+
asdf install awscli latest:2 # 2.11.15
46+
asdf install awscli latest:1 # 1.27.119
47+
48+
# Install a specific version
49+
asdf install awscli 2.11.15
50+
asdf install awscli 1.27.119
51+
52+
# Build and install v2 from from source
53+
asdf install awscli ref:2.11.15
54+
asdf install awscli "ref:$(asdf latest awscli 2)" # 2.11.15
4455

4556
# Set a version globally (on your ~/.tool-versions file)
4657
asdf global awscli latest
4758

4859
# Now awscli commands are available
49-
aws --help
60+
aws --version
5061
```
5162

63+
### v1 - Linux/MacOS/Windows
64+
65+
Only the pre-built installer is supported by this plugin for AWS CLI v1. If you need to build from source, install via `pip`.
66+
67+
Note: The pre-built installers require a Python 3.8+ distribution at install-time **and this Python must remain installed** as they're just creating an isolated virtualenv and copying their site-packages over. Refer to the [AWS CLI v1 Python version support matrix](https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-install.html#cli-chap-install-python) for which Pythons support which AWS CLI versions. If you remove the Python distribution used at install-time, **you must reinstall AWS CLI**.
68+
69+
### v2 - [Pre-built Installers](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-version.html)
70+
71+
The macOS flavor only provides an x86_64 binary. You *must* install Rosetta 2 if using Apple Silicon (M1/M2/arm64).
72+
73+
The Linux flavor provides both x86_64 and aarch64 binaries, but has dependencies on glibc, groff, and less. Alpine/musl users should build from source.
74+
75+
The Windows flavor technically works, but ASDF's support for Windows isn't 100% yet.
76+
77+
### v2 - [Build and install from source](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-source-install.html)
78+
79+
This is only supported starting from [v2.10.0 / 2023-02-15](https://github.com/aws/aws-cli/pull/7668)
80+
81+
Building and installing from source requires a Python 3.8+ distribution at build-time. This plugin uses the `--with-install-type=portable-exe` and `--with-download-deps` flags to download all required Python dependencies and freeze a static copy of the build-time Python distribution. After a successful installation, there are no dependencies to your build time environment, and the ASDF installs folder could be shared with another air-gapped system that did not have a Python installation.
82+
83+
---
84+
5285
Check [asdf](https://github.com/asdf-vm/asdf) readme for more instructions on how to
5386
install & manage versions.
5487

Diff for: bin/download

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
current_script_path=${BASH_SOURCE[0]}
6+
plugin_dir=$(dirname "$(dirname "${current_script_path}")")
7+
8+
# shellcheck source=../lib/utils.bash
9+
. "${plugin_dir}/lib/utils.bash"
10+
11+
TOOL_NAME="awscli"
12+
CURL_OPTS=(-fsSL)
13+
14+
mkdir -p "${ASDF_DOWNLOAD_PATH}"
15+
16+
download_source() {
17+
local version download_path major_version
18+
version="$1"
19+
download_path="$2"
20+
major_version="${version:0:1}"
21+
22+
if [[ "${major_version}" = "2" ]]; then
23+
source_url="https://awscli.amazonaws.com/awscli-${version}.tar.gz"
24+
filename="awscli.tar.gz"
25+
source_file="${download_path}/${filename}"
26+
curl "${CURL_OPTS[@]}" -o "${source_file}" -C - "${source_url}" || fail "Could not download ${source_url}"
27+
tar -xzf "${source_file}" -C "${download_path}" --strip-components=1 || fail "Could not extract ${source_file}"
28+
rm "${source_file}"
29+
else
30+
fail "asdf-${TOOL_NAME} does not support downloading from source for major version v${major_version}"
31+
fi
32+
}
33+
34+
download_release() {
35+
local version download_path major_version
36+
version="$1"
37+
download_path="$2"
38+
major_version="${version:0:1}"
39+
40+
if [[ "${major_version}" = "1" ]]; then
41+
release_url="https://s3.amazonaws.com/aws-cli/awscli-bundle-${version}.zip"
42+
filename="awscli-bundle.zip"
43+
elif [[ "${major_version}" = "2" ]]; then
44+
if [[ "${OS_NAME}" = "Linux" ]]; then
45+
if [[ "${OS_ARCH}" = "x86_64" || "${OS_ARCH}" = "aarch64" ]]; then
46+
release_url="https://awscli.amazonaws.com/awscli-exe-linux-${OS_ARCH}-${version}.zip"
47+
filename="awscliv2.zip"
48+
else
49+
fail "asdf-${TOOL_NAME} does not support ${OS_ARCH} on ${OS_NAME}"
50+
fi
51+
elif [[ "${OS_NAME}" = "Darwin" ]]; then
52+
release_url="https://awscli.amazonaws.com/AWSCLIV2-${version}.pkg"
53+
filename="AWSCLIV2.pkg"
54+
elif [[ "${OS_NAME}" = "Windows_NT" ]]; then
55+
release_url="https://awscli.amazonaws.com/AWSCLIV2-${version}.msi"
56+
filename="AWSCLIV2.msi"
57+
else
58+
fail "asdf-${TOOL_NAME} does not support OS distribution ${OS_NAME}"
59+
fi
60+
else
61+
fail "asdf-${TOOL_NAME} does not support major version v${version}"
62+
fi
63+
64+
release_file="${download_path}/${filename}"
65+
curl "${CURL_OPTS[@]}" -o "${release_file}" "${release_url}" || fail "Could not download ${release_url}"
66+
if [[ "${release_file: -3}" = "zip" ]]; then
67+
unzip -oq "${release_file}" -d "${download_path}"
68+
rm "${release_file}"
69+
fi
70+
}
71+
72+
if [ "${ASDF_INSTALL_TYPE}" = "version" ]; then
73+
download_release "${ASDF_INSTALL_VERSION}" "${ASDF_DOWNLOAD_PATH}"
74+
elif [ "${ASDF_INSTALL_TYPE}" = "ref" ]; then
75+
download_source "${ASDF_INSTALL_VERSION}" "${ASDF_DOWNLOAD_PATH}"
76+
fi

0 commit comments

Comments
 (0)