Skip to content

Commit 9c8600e

Browse files
authored
scripts: generate-changelog and put BASIC registry scanning (#897)
* Script to generate changelog during release process * During publish, add command to put registry scanning config. * generate-changelog script: add bash flags
1 parent 55eba80 commit 9c8600e

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

scripts/generate_changelog.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
set -xeuo pipefail
3+
4+
# Initialize variables
5+
next_token=""
6+
all_tags=()
7+
8+
# Get all amazonlinux container image tags
9+
while true; do
10+
if [ -z "$next_token" ]; then
11+
response=$(curl -sSL \
12+
--header "Content-Type: application/json" \
13+
--request POST \
14+
--data '{"registryAliasName":"amazonlinux","repositoryName":"amazonlinux","maxResults":250}' \
15+
https://api.us-east-1.gallery.ecr.aws/describeImageTags)
16+
else
17+
response=$(curl -sSL \
18+
--header "Content-Type: application/json" \
19+
--request POST \
20+
--data "{\"registryAliasName\":\"amazonlinux\",\"repositoryName\":\"amazonlinux\",\"nextToken\":\"$next_token\",\"maxResults\":250}" \
21+
https://api.us-east-1.gallery.ecr.aws/describeImageTags)
22+
fi
23+
24+
# Extract tags and add them to the array
25+
tags=$(echo "$response" | jq -r '.imageTagDetails[].imageTag')
26+
all_tags+=($tags)
27+
28+
# Check if there's a next token
29+
next_token=$(echo "$response" | jq -r '.nextToken')
30+
if [[ "$next_token" == "null" ]]; then
31+
break
32+
fi
33+
done
34+
35+
# Find the most recent AL2 tag
36+
most_recent_al2=$(printf '%s\n' "${all_tags[@]}" | grep '^2\.' | grep -v minimal | grep -v arm | grep -v amd | sort -V | tail -n 1)
37+
38+
# Read the JSON file
39+
json_file="linux.version"
40+
json_content=$(cat "$json_file")
41+
42+
# Extract values using jq
43+
version=$(echo "$json_content" | jq -r '.linux.version')
44+
fluent_bit_version=$(echo "$json_content" | jq -r '.linux."fluent-bit"')
45+
cloudwatch_plugin_version=$(echo "$json_content" | jq -r '.linux."cloudwatch-plugin"')
46+
kinesis_plugin_version=$(echo "$json_content" | jq -r '.linux."kinesis-plugin"')
47+
firehose_plugin_version=$(echo "$json_content" | jq -r '.linux."firehose-plugin"')
48+
49+
# Generate the changelog entry
50+
cat << EOF
51+
### $version
52+
This release includes:
53+
* Fluent Bit [$fluent_bit_version](https://github.com/fluent/fluent-bit/tree/v$fluent_bit_version)
54+
* Amazon CloudWatch Logs for Fluent Bit ${cloudwatch_plugin_version#v}
55+
* Amazon Kinesis Streams for Fluent Bit ${kinesis_plugin_version#v}
56+
* Amazon Kinesis Firehose for Fluent Bit ${firehose_plugin_version#v}
57+
* Amazon Linux base container image version: $most_recent_al2
58+
59+
Compared to the previous release, this release adds:
60+
* Fix - TODO blah blah [#TODO](https://github.com/amazon-contributing/upstream-to-fluent-bit/pull/TODO)
61+
* Enhancement - TODO blah blah [#TODO](https://github.com/aws/aws-for-fluent-bit/pull/TODO)
62+
EOF

scripts/publish.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,8 @@ verify_ecr_image_scan() {
623623

624624
tagCount=$(aws ecr list-images --repository-name ${repo_uri} --region ${region} | jq -r '.imageIds[].imageTag' | grep -c ${tag} || echo "0")
625625
if [ "$tagCount" = '1' ]; then
626+
# one-time image scanning is only compatible with "BASIC" scanning type registries
627+
aws ecr put-registry-scanning-configuration --scan-type BASIC --region ${region}
626628
aws ecr start-image-scan --repository-name ${repo_uri} --image-id imageTag=${tag} --region ${region}
627629
aws ecr wait image-scan-complete --repository-name ${repo_uri} --region ${region} --image-id imageTag=${tag}
628630
highVulnerabilityCount=$(aws ecr describe-image-scan-findings --repository-name ${repo_uri} --region ${region} --image-id imageTag=${tag} | jq '.imageScanFindings.findingSeverityCounts.HIGH')
@@ -1252,4 +1254,4 @@ fi
12521254

12531255
if [ "${1}" = "cicd-check-image-version" ]; then
12541256
check_image_version ${AWS_FOR_FLUENT_BIT_VERSION}
1255-
fi
1257+
fi

0 commit comments

Comments
 (0)