diff --git a/.github/scripts/bom-details-to-releases.sh b/.github/scripts/bom-details-to-releases.sh index 8ec9b82e..c247ab15 100755 --- a/.github/scripts/bom-details-to-releases.sh +++ b/.github/scripts/bom-details-to-releases.sh @@ -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 @@ -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]') diff --git a/.github/scripts/get-releases.sh b/.github/scripts/get-releases.sh new file mode 100755 index 00000000..eed36d2e --- /dev/null +++ b/.github/scripts/get-releases.sh @@ -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}" diff --git a/.github/scripts/releases-to-index.sh b/.github/scripts/releases-to-index.sh index 92f95c69..8cd1084e 100755 --- a/.github/scripts/releases-to-index.sh +++ b/.github/scripts/releases-to-index.sh @@ -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 @@ -16,7 +17,7 @@ RELEASES=$( "${OUTPUT_FILE}" diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c19d6edd..d55e1b18 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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 | \ diff --git a/boms/infrastructure/aws/105-aws-vpc-openshift.yaml b/boms/infrastructure/aws/105-aws-vpc-openshift.yaml index 7e5b1fab..eee9e2a8 100644 --- a/boms/infrastructure/aws/105-aws-vpc-openshift.yaml +++ b/boms/infrastructure/aws/105-aws-vpc-openshift.yaml @@ -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: diff --git a/boms/infrastructure/aws/110-aws-vpc-openshift-standard.yaml b/boms/infrastructure/aws/110-aws-vpc-openshift-standard.yaml index bff9e621..86bff43d 100644 --- a/boms/infrastructure/aws/110-aws-vpc-openshift-standard.yaml +++ b/boms/infrastructure/aws/110-aws-vpc-openshift-standard.yaml @@ -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: diff --git a/boms/infrastructure/azure/101-azure-vnet-std.yaml b/boms/infrastructure/azure/101-azure-vnet-std.yaml index 1718a903..390f8e01 100644 --- a/boms/infrastructure/azure/101-azure-vnet-std.yaml +++ b/boms/infrastructure/azure/101-azure-vnet-std.yaml @@ -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: diff --git a/boms/infrastructure/azure/105-azure-aro-std.yaml b/boms/infrastructure/azure/105-azure-aro-std.yaml index 31f5e0d3..47049c1a 100644 --- a/boms/infrastructure/azure/105-azure-aro-std.yaml +++ b/boms/infrastructure/azure/105-azure-aro-std.yaml @@ -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 diff --git a/boms/infrastructure/azure/110-azure-byo-certificate.yaml b/boms/infrastructure/azure/110-azure-byo-certificate.yaml index be28b63d..0877c579 100644 --- a/boms/infrastructure/azure/110-azure-byo-certificate.yaml +++ b/boms/infrastructure/azure/110-azure-byo-certificate.yaml @@ -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