Skip to content

Commit 24e9b13

Browse files
authored
Adding release kickoff github action (#1036)
1 parent 2498c54 commit 24e9b13

File tree

4 files changed

+201
-0
lines changed

4 files changed

+201
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: InitiateRelease
2+
3+
# TODO: We will be changing this to run on a regular scheduled interval once all of the infrastructure has been set up.
4+
on:
5+
workflow_dispatch:
6+
7+
jobs:
8+
GenerateConfig:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
stage_exit_code: ${{ steps.stage.outputs.stage_exit_code }}
12+
push_exit_code: ${{ steps.push.outputs.push_exit_code }}
13+
pr_exit_code: ${{ steps.pr.outputs.pr_exit_code }}
14+
permissions:
15+
id-token: write
16+
contents: write
17+
pull-requests: write
18+
env:
19+
GH_TOKEN: ${{ github.token }}
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v5
23+
- name: Create Release Branch
24+
run: |
25+
date=$(date '+%Y%m%d')
26+
git checkout -b release-${date}
27+
- name: Configure Bot Alias
28+
run: |
29+
git config --global user.name "GenerateConfig Action"
30+
git config --global user.email "[email protected]"
31+
- name: Check Update
32+
run: ./scripts/check-update.sh
33+
- name: Check for changes
34+
id: stage
35+
run: |
36+
# Git diff returns exit code of 1 when there is a change staged
37+
# We need the set statements to prevent erroring out
38+
set +e
39+
git diff --cached --quiet
40+
if [[ $? -ne 0 ]]; then echo "stage_exit_code=42" >> "$GITHUB_OUTPUT"; else echo "stage_exit_code=0" >> "$GITHUB_OUTPUT"; fi
41+
set -e
42+
- name: Commit and Push Changes
43+
id: push
44+
if: ${{ steps.stage.outputs.stage_exit_code == 42 }}
45+
run: |
46+
date=$(date '+%Y%m%d')
47+
git commit -m "Release ${date}"
48+
git status
49+
git push --set-upstream origin release-${date}
50+
echo "push_exit_code=$?" >> "$GITHUB_OUTPUT"
51+
- name: Open PR for Branch
52+
id: pr
53+
if: ${{ steps.stage.outputs.stage_exit_code == 42 && steps.push.outputs.push_exit_code == 0 }}
54+
run: |
55+
date=$(date '+%Y%m%d')
56+
gh pr create --base mainline --head release-${date} --title "Release ${date}" --body "Dummy Release PR"
57+
echo "pr_exit_code=$?" >> "$GITHUB_OUTPUT"
58+
MetricPublish:
59+
needs: GenerateConfig
60+
if: success() || failure()
61+
runs-on: ubuntu-latest
62+
permissions:
63+
id-token: write
64+
contents: read
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v5
68+
- name: Configure AWS Credentials
69+
uses: aws-actions/configure-aws-credentials@v5
70+
with:
71+
# TODO: Add the role as a secret once infrastructure has been set up.
72+
role-to-assume: ${{ secrets.CW_METRIC_ROLE }}
73+
aws-region: us-west-2
74+
- name: Failure Scenario
75+
if: ${{ needs.GenerateConfig.result == 'failure' }}
76+
run: |
77+
# TODO: Cloudwatch metric namespace will need to be created
78+
echo "ERROR: Encounter error when checking for new release."
79+
aws cloudwatch put-metric-data --metric-name FluentBitGithubActionFailure --namespace FluentBitRelease --value "-1"
80+
- name: Release Kickoff Scenario
81+
if: ${{ needs.GenerateConfig.outputs.stage_exit_code == 42 }}
82+
run: |
83+
# TODO: Cloudwatch metric namespace will need to be created
84+
echo "Kicking off new release."
85+
aws cloudwatch put-metric-data --metric-name FluentBitGithubActionKickoff --namespace FluentBitRelease --value 1
86+
- name: No Release Scenario
87+
if: ${{ needs.GenerateConfig.outputs.stage_exit_code == 0 }}
88+
run: |
89+
# TODO: Cloudwatch metric namespace will need to be created
90+
echo "No new release needed at this time."
91+
aws cloudwatch put-metric-data --metric-name FluentBitGithubActionKickoff --namespace FluentBitRelease --value 0

.github/workflows/postkickoff.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Post-release merge action
2+
run-name: Post-release merge action
3+
4+
on:
5+
pull_request:
6+
types: [closed]
7+
branches: [mainline]
8+
9+
jobs:
10+
ResetReleaseMetric:
11+
if: github.event.pull_request.merged == true && startsWith(github.head_ref, 'release-')
12+
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write
15+
contents: read
16+
steps:
17+
- uses: actions/checkout@v5
18+
- name: Run on merged PR
19+
run: echo "PR merged from ${{ github.head_ref }} to ${{ github.base_ref }}"
20+
- name: Configure AWS Credentials
21+
uses: aws-actions/configure-aws-credentials@v5
22+
with:
23+
# TODO: Add the role as a secret once infrastructure has been set up.
24+
role-to-assume: ${{ secrets.CW_METRIC_ROLE }}
25+
aws-region: us-west-2
26+
- name: Reset release alarm
27+
run: aws cloudwatch put-metric-data --metric-name FluentBitGithubActionKickoff --namespace FluentBitRelease --value 0

linux.version

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,35 @@
33
"linux": {
44
"major-version": "2",
55
"version": "2.34.1.20251031",
6+
"release-version": "2.34.1.20251031",
67
"latest": "true",
78
"build": "1",
89
"fluent-bit": "1.9.10",
10+
"release-fluent-bit": "1.9.10",
911
"kinesis-plugin": "v1.10.3",
1012
"firehose-plugin": "v1.7.2",
1113
"cloudwatch-plugin": "v1.9.4",
1214
"al-tag": "2",
1315
"flb-repository": "https://github.com/amazon-contributing/upstream-to-fluent-bit.git",
16+
"amazon-linux-sha": "",
1417
"publish": "true"
1518
}
1619
},
1720
{
1821
"linux": {
1922
"major-version": "3",
2023
"version": "3.0.0",
24+
"release-version": "3.0.0",
2125
"latest": "false",
2226
"build": "1",
2327
"fluent-bit": "v4.1.1",
28+
"release-fluent-bit": "v4.1.1",
2429
"kinesis-plugin": "v1.10.3",
2530
"firehose-plugin": "v1.7.2",
2631
"cloudwatch-plugin": "v1.9.4",
2732
"al-tag": "2023",
2833
"flb-repository": "https://github.com/fluent/fluent-bit.git",
34+
"amazon-linux-sha": "",
2935
"publish": "false"
3036
}
3137
}

scripts/check-update.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
readonly VERSION_FILE="linux.version"
5+
readonly ECR_REPO="public.ecr.aws/amazonlinux/amazonlinux"
6+
7+
# List of docker tags that we want to clean up after
8+
tags_to_cleanup=()
9+
10+
# Cleanup function that removes the pulled AL docker images
11+
cleanup() {
12+
for i in "${tags_to_cleanup[@]}"; do
13+
docker rmi "${ECR_REPO}:$i" || true
14+
done
15+
}
16+
17+
# Helper function to update the specific JSON key/field within the release config file
18+
update_json_field() {
19+
local key="$1" field="$2" value="$3"
20+
jq ".[$key].linux.\"$field\" = \"$value\"" "$VERSION_FILE" > tmp.json && mv tmp.json "$VERSION_FILE"
21+
}
22+
23+
# Function that checks and updates the release config file for any of the following:
24+
# - New Amazon Linux docker image (tracked by image SHA)
25+
# - New upstream Fluentbit version to consumed
26+
# - New AWS Fluentbit version to be released (Updated to pull in any other updates/changes.)
27+
check_and_update() {
28+
local update="false"
29+
30+
for i in $(jq 'keys[]' "$VERSION_FILE"); do
31+
current_sha=$(jq -r ".[$i].linux.\"amazon-linux-sha\"" "$VERSION_FILE")
32+
tag=$(jq -r ".[$i].linux.\"al-tag\"" "$VERSION_FILE")
33+
34+
if ! docker pull "${ECR_REPO}:$tag"; then
35+
echo "Warning: Failed to pull ${ECR_REPO}:$tag" >&2
36+
continue
37+
fi
38+
39+
tags_to_cleanup+=("$tag")
40+
new_al_sha=$(docker inspect --format='{{index .RepoDigests 0}}' "${ECR_REPO}:$tag")
41+
42+
if [[ "$new_al_sha" != "$current_sha" ]]; then
43+
echo "New base amazon linux image for $tag. Updating..."
44+
update_json_field "$i" "amazon-linux-sha" "$new_al_sha"
45+
update="true"
46+
fi
47+
48+
curr_fluentbit_version=$(jq -r ".[$i].linux.\"fluent-bit\"" "$VERSION_FILE")
49+
release_fluentbit_version=$(jq -r ".[$i].linux.\"release-fluent-bit\"" "$VERSION_FILE")
50+
if [[ "$curr_fluentbit_version" != "$release_fluentbit_version" ]]; then
51+
echo "Upgrading to new Fluentbit version."
52+
update_json_field "$i" "fluent-bit" "$release_fluentbit_version"
53+
update="true"
54+
fi
55+
56+
curr_aws_fb_version=$(jq -r ".[$i].linux.\"version\"" "$VERSION_FILE")
57+
release_aws_fb_version=$(jq -r ".[$i].linux.\"release-version\"" "$VERSION_FILE")
58+
if [[ "$curr_aws_fb_version" != "$release_aws_fb_version" ]]; then
59+
echo "Upgrading to new AWS Fluentbit version."
60+
update_json_field "$i" "version" "$release_aws_fb_version"
61+
update="true"
62+
fi
63+
done
64+
65+
if [[ "$update" = "true" ]]; then
66+
git add "$VERSION_FILE"
67+
git status
68+
fi
69+
}
70+
71+
main() {
72+
check_and_update
73+
}
74+
75+
trap cleanup EXIT
76+
77+
main "$@"

0 commit comments

Comments
 (0)