-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
134 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[bin/**] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
?.* | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
*logs | ||
*actions | ||
*notifications | ||
*tools | ||
plugins | ||
user_trunk.yaml | ||
user.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
rules: | ||
quoted-strings: | ||
required: only-when-needed | ||
extra-allowed: ["{|}"] | ||
empty-values: | ||
forbid-in-block-mappings: true | ||
forbid-in-flow-mappings: true | ||
key-duplicates: {} | ||
octal-values: | ||
forbid-implicit-octal: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,93 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
shopt -s inherit_errexit 2>/dev/null || true | ||
|
||
[[ -z ${ASDF_INSTALL_TYPE+x} ]] && echo "ASDF_INSTALL_TYPE is required" && exit 1 | ||
[[ -z ${ASDF_INSTALL_VERSION+x} ]] && echo "ASDF_INSTALL_VERSION is required" && exit 1 | ||
[[ -z ${ASDF_INSTALL_PATH+x} ]] && echo "ASDF_INSTALL_PATH is required" && exit 1 | ||
|
||
install() { | ||
function gh_curl() { | ||
if [[ -n ${GITHUB_TOKEN-} ]]; then | ||
curl -fLsS -H "Authorization: token ${GITHUB_TOKEN}" "$@" | ||
elif [[ -n ${GITHUB_API_TOKEN-} ]]; then | ||
curl -fLsS -H "Authorization: token ${GITHUB_API_TOKEN}" "$@" | ||
else | ||
curl -fLsS "$@" | ||
fi | ||
} | ||
|
||
function install() { | ||
# set -x | ||
local install_type=$1 | ||
[[ ${install_type} != "version" ]] && echo "intall type, ${install_type}, is not supported" && exit 1 | ||
[[ ${install_type} != "version" ]] && echo "install type, ${install_type}, is not supported" && exit 1 | ||
|
||
local prefix="v" | ||
local version=$2 | ||
local install_path=$3 | ||
|
||
local tmp_download_dir | ||
|
||
tmp_download_dir=$(mktemp -d -t asdf.XXXXXXXX) | ||
|
||
local bin_install_path="${install_path}/bin" | ||
|
||
local platform | ||
platform=$(uname) | ||
platform=$(uname -s) | ||
|
||
local arch | ||
arch=$(uname -m) | ||
case "$(uname -m)" in | ||
i386 | i686 | x86) arch="i386" ;; | ||
aarch64) arch="arm64" ;; | ||
*) arch="$(uname -m)" ;; | ||
esac | ||
|
||
local download_url | ||
download_url="https://github.com/google/go-containerregistry/releases/download/v${version}/go-containerregistry_${platform}_${arch}.tar.gz" | ||
local checksum_url | ||
|
||
local repo="google/go-containerregistry" | ||
local download_filename="go-containerregistry_${platform}_${arch}.tar.gz" | ||
local checksum_filename="checksums.txt" | ||
|
||
if [[ -n ${GITHUB_TOKEN-} ]] || [[ -n ${GITHUB_API_TOKEN-} ]]; then | ||
local asset_url | ||
asset_url="https://api.github.com/repos/${repo}/releases/tags/${prefix}${version}" | ||
download_url=$(gh_curl -H "Accept: application/vnd.github.v3.raw" "${asset_url}" | jq -r ".assets | map(select(.name == \"${download_filename}\"))[0].url") | ||
if [[ ${download_url} == null ]]; then | ||
echo "Asset ${download_filename} not found in a release ${prefix}${version}." | ||
exit 1 | ||
fi | ||
checksum_url=$(gh_curl -H "Accept: application/vnd.github.v3.raw" "${asset_url}" | jq -r ".assets | map(select(.name == \"${checksum_filename}\"))[0].url") | ||
if [[ ${checksum_url} == null ]]; then | ||
echo "Asset ${checksum_filename} not found in a release ${prefix}${version}." | ||
exit 1 | ||
fi | ||
else | ||
download_url="https://github.com/${repo}/releases/download/${prefix}${version}/${download_filename}" | ||
checksum_url="https://github.com/${repo}/releases/download/${prefix}${version}/${checksum_filename}" | ||
fi | ||
|
||
set -x | ||
echo "Downloading ${download_filename} from release ${prefix}${version} from ${download_url}" | ||
|
||
mkdir -p "${tmp_download_dir}" | ||
|
||
pushd "${tmp_download_dir}" >/dev/null | ||
|
||
gh_curl -H "Accept: application/octet-stream" -o "${download_filename}" "${download_url}" | ||
|
||
if command -v shasum >/dev/null; then | ||
gh_curl -H "Accept: application/octet-stream" "${checksum_url}" | awk "\$2 == \"${download_filename}\" {print}" | shasum -a 256 -c | ||
elif command -v sha256sum >/dev/null; then | ||
gh_curl -H "Accept: application/octet-stream" "${checksum_url}" | awk "\$2 == \"${download_filename}\" {print}" | sha256sum -c | ||
fi | ||
|
||
mkdir -p "${bin_install_path}" | ||
|
||
echo "Downloading go-containerregistry from ${download_url}" | ||
cd "${bin_install_path}" | ||
curl -sL "${download_url}" | tar zx | ||
tar zxf "${download_filename}" | ||
find "${tmp_download_dir}" -type f -perm -a=x -print0 | xargs -0 -I {} cp -fp {} "${bin_install_path}" | ||
|
||
popd >/dev/null | ||
} | ||
|
||
install "${ASDF_INSTALL_TYPE}" "${ASDF_INSTALL_VERSION}" "${ASDF_INSTALL_PATH}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
releases_path=https://api.github.com/repos/google/go-containerregistry/releases | ||
cmd="curl -s" | ||
if [[ -n ${GITHUB_API_TOKEN} ]]; then | ||
cmd="${cmd} -H 'Authorization: token ${GITHUB_API_TOKEN}'" | ||
fi | ||
set -euo pipefail | ||
shopt -s inherit_errexit 2>/dev/null || true | ||
|
||
cmd="${cmd} ${releases_path}" | ||
function gh_curl() { | ||
if [[ -n ${GITHUB_TOKEN-} ]]; then | ||
curl -s -H "Authorization: token ${GITHUB_TOKEN}" "$@" | ||
elif [[ -n ${GITHUB_API_TOKEN-} ]]; then | ||
curl -s -H "Authorization: token ${GITHUB_API_TOKEN}" "$@" | ||
else | ||
curl -s "$@" | ||
fi | ||
} | ||
|
||
function filter_versions() { | ||
grep -E '^[0-9]' | ||
} | ||
|
||
function 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}' | ||
} | ||
|
||
echo $(eval "${cmd}" | grep -oE 'tag_name": ".{1,15}",' | sed 's/tag_name\": \"v//;s/\",//' | sort_versions) | ||
repo="google/go-containerregistry" | ||
releases_path=https://api.github.com/repos/${repo}/releases | ||
|
||
gh_curl "${releases_path}" | grep -oE 'tag_name": "v.{1,15}",' | sed 's/tag_name\": \"v//;s/\",//' | filter_versions | sort_versions | xargs echo |