Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions hack/snyk-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
set -e
set -o pipefail

function get_latest_minor_version_tags() {
count=$1

git tag -l \
| sed -E 's/(v[0-9]\.[0-9]+).*/\1/' \
| sort -Vu \
| tail -n "$count"
}

function get_latest_patch_versions() {
count=$1

while read -r minor; do
git tag -l | grep "^$minor" | sort -V | tail -n 1
done < <(get_latest_minor_version_tags "$count")
}

npm install snyk snyk-to-html --location=global

# Choose the branch where docs changes will actually be written.
Expand Down Expand Up @@ -39,24 +56,14 @@ git checkout master

minor_version=$(git tag -l | sort -V | tail -n 1 | grep -Eo '[0-9]+\.[0-9]+')
patch_num=$(git tag -l | grep "v$minor_version." | grep -o "[a-z[:digit:]-]*$" | sort -V | tail -n 1)
version="v$minor_version.$patch_num"
versions="master "

version_count=3
# When the most recent version is still a release candidate, get reports for 4 versions (so the 3 most recent stable
# releases are included).
if [[ $patch_num == "0-rc"* ]]; then version_count=4; fi
versions="$(get_latest_patch_versions "$version_count")"

for i in $(seq "$version_count"); do
if [ "$version" == "" ]; then break; fi
# Nightmare code to get the most recent patches of the three most recent minor versions.
versions+="$version "
minor_num=$(printf '%s' "$minor_version" | sed -E 's/[0-9]+\.//')
minor_num=$((minor_num-1))
minor_version=$(printf '%s' "$minor_version" | sed -E "s/\.[0-9]+$/.$minor_num/g")
patch_num=$(git tag -l | grep "v$minor_version." | grep -o "[a-z[:digit:]-]*$" | sort -V | tail -n 1)
version="v$minor_version.$patch_num"
done
echo "Analyzing versions: $versions"

for version in $versions; do
printf '\n%s\n\n' "### $version" >> "$argocd_dir/docs/snyk/index.md"
Expand Down
Loading