Skip to content

Commit

Permalink
Adds get-releases script and updates boms
Browse files Browse the repository at this point in the history
- Touches boms to force release

Signed-off-by: Sean Sundberg <seansund@us.ibm.com>
  • Loading branch information
seansund committed Feb 2, 2023
1 parent e06eabe commit 062caed
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 14 deletions.
5 changes: 3 additions & 2 deletions .github/scripts/bom-details-to-releases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ while read -r bom; do
fi

echo " Creating tag: ${release_name}" 1>&2
git tag -a "${release_name}" -m "${version} release of ${name} bom" 1> /dev/null 2> /dev/null
git tag -a "${release_name}" -m "${version} release of ${name} bom" 1> /dev/null
git push --tags 1> /dev/null 2> /dev/null

echo " Copying asset to /tmp/asset/${name}" 1>&2
mkdir -p "/tmp/asset/${name}" 1> /dev/null
cp "${file}" "/tmp/asset/${name}/bom.yaml" 1> /dev/null

Expand All @@ -37,7 +38,7 @@ while read -r bom; do
--title "${release_name}" \
--notes "${version} release of ${name} bom" \
--repo "${REPO}" \
"/tmp/asset/${name}/bom.yaml" 1> /dev/null 2> /dev/null || continue
"/tmp/asset/${name}/bom.yaml" 1> /dev/null || continue

echo "Release created: ${release_name}" 1>&2
RELEASES=$(echo "${RELEASES}" | jq --argjson bom "${bom}" '. += [$bom]')
Expand Down
57 changes: 57 additions & 0 deletions .github/scripts/get-releases.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash

REPO="${1:-github.com/cloud-native-toolkit/automation-solutions}"

BASE_URL="https://github.com/cloud-native-toolkit/automation-solutions/releases/download"

if ! command -v yq 1> /dev/null 2> /dev/null; then
echo "yq not installed" 1>&2
exit 1
fi
if ! command -v jq 1> /dev/null 2> /dev/null; then
echo "jq not installed" 1>&2
exit 1
fi

TAB=$'\t'
RELEASES=$(gh release list --repo "${REPO}" | grep -v TITLE | sed -E "s/^([^ ${TAB}]+)[ ${TAB}]+.*/\1/g")

RESULT="[]"

bom_details() {
local bom="$1"

name=$(yq e '.metadata.name' "${bom}")
version=$(yq e '.spec.version // "v1.0.0"' "${bom}")
display_name=$(yq e '.metadata.annotation.displayName // ""' "${bom}")
description=$(yq e '.metadata.annotation.description // ""' "${bom}")
category=$(yq e '.metadata.labels.type // ""' "${bom}")
release_name="${name}_${version}"

if [[ -z "${display_name}" ]]; then
display_name="${name}"
fi
if [[ -z "${description}" ]]; then
description="Layer for ${name}"
fi

RESULT=$(echo "${RESULT}" | jq --arg name "${name}" --arg file "${bom}" --arg version "${version}" --arg release "${release_name}" --arg displayName "${display_name}" --arg description "${description}" --arg category "${category}" '. += [{"name": $name, "version": $version, "release_name": $release, "display_name": $displayName, "description": $description, "category": $category, "file": $file}]')
}

while read -r release_name; do

release_url="${BASE_URL}/${release_name}/bom.yaml"

mkdir -p "/tmp/asset/${release_name}"
curl -Lso "/tmp/asset/${release_name}/bom.yaml" "${release_url}"

if ! yq e '.' "/tmp/asset/${release_name}/bom.yaml" 1> /dev/null 2> /dev/null; then
echo "Failed to parse file: /tmp/asset/${release_name}/bom.yaml" 1>&2
continue
fi

bom_details "/tmp/asset/${release_name}/bom.yaml"

done < <(echo "${RELEASES}")

echo "${RESULT}"
15 changes: 11 additions & 4 deletions .github/scripts/releases-to-index.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

INDEX_FILE="${1:-index.yaml}"
INPUT_FILE="${1:-index.yaml}"
OUTPUT_FILE="${2:-/dev/stdout}"

if ! command -v yq 1> /dev/null 2> /dev/null; then
echo "yq not installed" 1>&2
Expand All @@ -16,7 +17,7 @@ RELEASES=$(</dev/stdin)

BASE_URL="https://github.com/cloud-native-toolkit/automation-solutions/releases/download"

INDEX_JSON=$(yq e '.' -o json "${INDEX_FILE}")
INDEX_JSON=$(yq e '.' -o json "${INPUT_FILE}")

while read -r release; do
name=$(echo "${release}" | jq -r '.name')
Expand All @@ -32,7 +33,13 @@ while read -r release; do

release_json=$(echo "${INDEX_JSON}" | jq --arg name "${name}" -c '.boms[] | select(.name == $name)')
if [[ -n "${release_json}" ]]; then
versions=$(echo "${release_json}" | jq -c --argjson version "${version_json}" '.versions | reverse | . += [$version] | reverse')
versions=$(echo "${release_json}" | jq -c '.versions')

if [[ $(echo "${versions}" | jq -r --arg version "${version}" '.[] | select(.version == $version) | .version // ""') == "${version}" ]]; then
versions=$(echo "${versions}" | jq -c --arg version "${version}" --arg url "${release_url}" 'map((select(.version == $version) | .metadataUrl) |= $url)')
else
versions=$(echo "${versions}" | jq -c --argjson version "${version_json}" '. | reverse | . += [$version] | reverse')
fi

release_json=$(echo "${release_json}" | jq -c --argjson versions "${versions}" '.versions = $versions')

Expand All @@ -45,4 +52,4 @@ while read -r release; do

done < <(echo "${RELEASES}" | jq -c '.[]')

echo "${INDEX_JSON}" | yq e -P '.' -
echo "${INDEX_JSON}" | yq e -P '.' - > "${OUTPUT_FILE}"
4 changes: 4 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ jobs:
output_file="/tmp/output/index.yaml"
cd main
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
echo "${{ steps.changed-files.outputs.all_changed_files }}" | \
tr " " "\n" | xargs -I{} echo "${PWD}/{}" | \
.github/scripts/bom-changes-to-details.sh | \
Expand Down
4 changes: 2 additions & 2 deletions boms/infrastructure/aws/105-aws-vpc-openshift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ metadata:
code: '105'
platform: aws
annotations:
displayName: AWS OpenShift Quickstart
description: Provision OpenShift on AWS
displayName: AWS OpenShift (ROSA) Quickstart
description: Provision ROSA managed OpenShift on AWS
spec:
version: v1.0.1
modules:
Expand Down
4 changes: 2 additions & 2 deletions boms/infrastructure/aws/110-aws-vpc-openshift-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ metadata:
code: '110'
platform: aws
annotations:
displayName: AWS OpenShift Standard
description: Provision OpenShift on AWS
displayName: AWS OpenShift (ROSA) Standard
description: Provision ROSA managed OpenShift on AWS
spec:
version: v1.0.1
modules:
Expand Down
2 changes: 1 addition & 1 deletion boms/infrastructure/azure/101-azure-vnet-std.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
platform: azure
code: '101'
annotations:
displayName: Azure Red Hat OpenShift Standard
displayName: Azure vnet Standard
description: Azure base infrastructure for OpenShift standard architecture
vpn/required: false
spec:
Expand Down
2 changes: 1 addition & 1 deletion boms/infrastructure/azure/105-azure-aro-std.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
code: '105'
annotations:
displayName: Azure Red Hat OpenShift (ARO) Standard
description: Azure ARO for Standard Architecture
description: Azure ARO managed OpenShift for Standard Architecture
vpn/required: 'true'
spec:
version: v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions boms/infrastructure/azure/110-azure-byo-certificate.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apiVersion: cloud.ibm.com/v1alpha1
kind: BillOfMaterial
metadata:
name: 111-supplied-certificate
name: 110-supplied-certificate
labels:
type: infrastructure
platform: azure
code: '111'
code: '110'
annotations:
displayName: Supplied Certificate
description: Supplied Certificate for OpenShift
Expand Down

0 comments on commit 062caed

Please sign in to comment.