11#! /bin/bash
22set -xeuo pipefail
33
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+
435# Find the most recent AL2 tag
5- most_recent_al2=$( ./scripts/most_recent_al2.sh )
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 )
637
738# Read the JSON file
839json_file=" linux.version"
@@ -15,142 +46,17 @@ cloudwatch_plugin_version=$(echo "$json_content" | jq -r '.linux."cloudwatch-plu
1546kinesis_plugin_version=$( echo " $json_content " | jq -r ' .linux."kinesis-plugin"' )
1647firehose_plugin_version=$( echo " $json_content " | jq -r ' .linux."firehose-plugin"' )
1748
18- changelog_commit=$( git log -n1 --pretty=format:%h CHANGELOG.md)
19- changelog_commit_date=" $( git show --no-patch --format=%ci $changelog_commit ) "
20- current_commit=$( git log -n1 --pretty=format:%h)
21-
22- # Test Overrides
23-
24-
25- upstream_changes=false
26- newer_upstream_changes=" "
27- if [ " ${# FLUENT_BIT_DIRECTORY} " -ge 1 ]; then
28- newer_upstream_changes=$( cd $FLUENT_BIT_DIRECTORY ; git log --pretty=format:%s --after " $changelog_commit_date " )
29- # If there are NOT newer changes
30- if [ ${# newer_upstream_changes} -le 1 ]; then
31- FLUENT_BIT_DIRECTORY=" "
32- fi
33- fi
34-
35- compared_string=" "
36-
37- add_changelog_changes=false
38- flb_has_changes=false
39- we_have_changes=false
40- if [ " ${# FLUENT_BIT_DIRECTORY} " -ge 1 ]; then
41- flb_has_changes=true
42- fi
43- if [ " $changelog_commit " != " $current_commit " ]; then
44- we_have_changes=true
45- fi
46-
47- if [ " $we_have_changes " = true ] || [ " $flb_has_changes " = true ]; then
48- compared_string="
49- Compared to the previous release, this release adds:"
50- commit_names=$( git log --pretty=format:%s " $changelog_commit " .." $current_commit " )
51- if [ " $flb_has_changes " = true ]; then
52- # Get commits from the upstream as well
53- # Add newline to separate from existing commits
54- commit_names+="
55- "
56- # Add FLB commit names to the list considered for changelog updates
57- commit_names+=" $newer_upstream_changes "
58- fi
59- original_ifs=$IFS
60- IFS="
61- "
62- for line in $commit_names
63- do
64- IFS=" "
65- found_label=false
66- for word in $line
67- do
68- # Look for an indication of what this commit is about
69- # unless we already are at the stage of collecting
70- # the name
71- if [ " $found_label " = false ]; then
72- # Factor out setting this to true if a
73- # label is found, reducing boilerplate
74- found_label=true
75- if [ " $word " = " feature:" ]; then
76- compared_string+="
77- * Feature - "
78- continue
79- elif [ " $word " = " enhancement:" ]; then
80- compared_string+="
81- * Enhancement - "
82- continue
83- elif [ " $word " = " fix:" ] || [ " $word " = " bugfix:" ]; then
84- compared_string+="
85- * Fix - "
86- continue
87- elif [ " $word " = " Fix" ]; then
88- compared_string+="
89- * Fix - "
90- # We don't continue for the enclosing elif,
91- # i.e. we add "Fix" as the first word
92- elif [ $( echo " $word " | grep " \(aws:\|out_cloudwatch_logs:\|out_s3:\|out_kinesis:\|filter_ecs:\|filter_kubernetes:\)" ) ]; then
93- change_type=" Enhancement"
94- for inner_word in $line
95- do
96- if [ $( echo " $inner_word " | grep ' \(fix\|Fix\|bugfix\)' ) ]; then
97- change_type=" Fix"
98- break
99- elif [ $( echo " $inner_word " | grep ' \(add\|Add\)' ) ]; then
100- change_type=" Feature"
101- break
102- elif [ $( echo " $inner_word " | grep ' \(allow\|support\)' ) ]; then
103- # Enhancement is the default
104- break
105- fi
106- done
107-
108- compared_string+="
109- * $change_type - "
110- continue
111- else
112- # No label was found
113- found_label=false
114- fi
115- fi
116- if [ " $found_label " = false ]; then
117- # If no label, skip this commit
118- break 1
119- else
120- # Add each word aside from the prefix to the commit changelog description
121- compared_string+=$word
122- compared_string+=" "
123- fi
124- done
125- IFS="
126- "
127- done
128- # Append newline to separate from the next changelog entry
129- compared_string+="
130- "
131- IFS=$original_ifs
132- fi
133-
13449# Generate the changelog entry
135-
136- new_changelog="
50+ cat << EOF
13751### $version
13852This release includes:
13953* Fluent Bit [$fluent_bit_version ](https://github.com/fluent/fluent-bit/tree/v$fluent_bit_version )
14054* Amazon CloudWatch Logs for Fluent Bit ${cloudwatch_plugin_version# v}
14155* Amazon Kinesis Streams for Fluent Bit ${kinesis_plugin_version# v}
14256* Amazon Kinesis Firehose for Fluent Bit ${firehose_plugin_version# v}
14357* Amazon Linux base container image version: $most_recent_al2
144- $compared_string "
145-
146- heads=$( head -n 1 CHANGELOG.md)
147- tails=$( tail -n +3 CHANGELOG.md)
148-
149- rm -f temp_changelog.txt
150- echo " $heads " >> temp_changelog.txt
151- echo " $new_changelog " >> temp_changelog.txt
152- echo " $tails " >> temp_changelog.txt
153-
154- mv -f temp_changelog.txt CHANGELOG.md
155- rm -f temp_changelog.txt
15658
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
0 commit comments