Skip to content

Commit 40516ed

Browse files
authored
Automate creation of the changelog after the release build. After the verification and tagging this will create a PR with a changelog between tags. This also updates some plugin versions used in the release GitHub Action to the latest versions. (#6742)
Signed-off-by: David Venable <dlv@amazon.com>
1 parent 3bd796d commit 40516ed

2 files changed

Lines changed: 102 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ permissions:
2727
id-token: write
2828
contents: write
2929
issues: write
30+
pull-requests: write
3031

3132
jobs:
3233
build:
@@ -35,7 +36,7 @@ jobs:
3536

3637
steps:
3738
- name: Set up JDK
38-
uses: actions/setup-java@v4
39+
uses: actions/setup-java@v5
3940
with:
4041
java-version: 11
4142
distribution: temurin
@@ -47,7 +48,7 @@ jobs:
4748
run: ./gradlew --parallel --max-workers 2 build
4849

4950
- name: Configure AWS Credentials
50-
uses: aws-actions/configure-aws-credentials@v1
51+
uses: aws-actions/configure-aws-credentials@v6
5152
with:
5253
role-to-assume: ${{ secrets.RELEASE_IAM_ROLE }}
5354
aws-region: us-east-1
@@ -66,7 +67,7 @@ jobs:
6667

6768
- name: Log into Amazon ECR Public
6869
id: login-ecr
69-
uses: docker/login-action@v1
70+
uses: docker/login-action@v4
7071
with:
7172
registry: public.ecr.aws
7273
env:
@@ -134,12 +135,17 @@ jobs:
134135
permissions:
135136
contents: write
136137
issues: write
138+
outputs:
139+
version: ${{ steps.get_version.outputs.version }}
137140

138141
steps:
139142
- name: Checkout Data Prepper
140143
uses: actions/checkout@v6
141144
- name: Get Version
142-
run: grep '^version=' gradle.properties >> $GITHUB_ENV
145+
id: get_version
146+
run: |
147+
grep '^version=' gradle.properties >> $GITHUB_ENV
148+
echo "version=$(grep '^version=' gradle.properties | cut -d'=' -f2)" >> $GITHUB_OUTPUT
143149
144150
- name: Get Approvers
145151
id: get_approvers
@@ -191,3 +197,50 @@ jobs:
191197
tag_name: 'refs/tags/${{ env.version }}'
192198
files: |
193199
release-description.yaml
200+
201+
generate-changelog:
202+
runs-on: ubuntu-latest
203+
needs: promote
204+
205+
steps:
206+
- name: Checkout Data Prepper
207+
uses: actions/checkout@v6
208+
with:
209+
fetch-depth: 0
210+
persist-credentials: false
211+
212+
- name: Fetch Tags
213+
run: git fetch origin --tags
214+
215+
- name: Setup Node.js
216+
uses: actions/setup-node@v4
217+
with:
218+
node-version: 22
219+
220+
- name: Install git-release-notes
221+
run: npm install -g git-release-notes
222+
223+
- name: Generate Changelog
224+
run: release/script/changelog/generate-changelog.sh ${{ needs.promote.outputs.version }}
225+
226+
- name: GitHub App token
227+
id: github_app_token
228+
uses: tibdex/github-app-token@v2
229+
with:
230+
app_id: ${{ secrets.APP_ID }}
231+
private_key: ${{ secrets.APP_PRIVATE_KEY }}
232+
233+
- name: Create Pull Request
234+
uses: peter-evans/create-pull-request@v6
235+
with:
236+
token: ${{ steps.github_app_token.outputs.token }}
237+
add-paths: |
238+
release/release-notes/data-prepper.change-log-${{ needs.promote.outputs.version }}.md
239+
commit-message: 'Add Data Prepper ${{ needs.promote.outputs.version }} changelog.'
240+
signoff: true
241+
branch: changelog-${{ needs.promote.outputs.version }}
242+
delete-branch: true
243+
base: main
244+
title: 'Data Prepper ${{ needs.promote.outputs.version }} changelog'
245+
body: |
246+
Adds the Data Prepper ${{ needs.promote.outputs.version }} changelog generated by git-release-notes.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright OpenSearch Contributors
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
# The OpenSearch Contributors require contributions made to
8+
# this file be licensed under the Apache-2.0 license or a
9+
# compatible open source license.
10+
#
11+
12+
# Generates a changelog for a Data Prepper release using git-release-notes.
13+
#
14+
# Usage: generate-changelog.sh <version>
15+
#
16+
# The previous version is determined automatically from existing git tags.
17+
# Requires git-release-notes to be installed (npm install -g git-release-notes).
18+
19+
set -e
20+
21+
VERSION=$1
22+
23+
if [ -z "$VERSION" ]; then
24+
echo "Usage: $0 <version>"
25+
echo " <version> The release version (e.g. 2.15.0)"
26+
exit 1
27+
fi
28+
29+
PREVIOUS_VERSION=$(git tag --sort=-version:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | awk -v ver="$VERSION" 'found {print; exit} $0 == ver {found=1}')
30+
31+
if [ -z "$PREVIOUS_VERSION" ]; then
32+
echo "Error: Could not determine the previous version from git tags."
33+
echo "Make sure the tag '$VERSION' exists and there is an earlier release tag."
34+
exit 1
35+
fi
36+
37+
echo "Generating changelog for ${PREVIOUS_VERSION}..${VERSION}"
38+
39+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
40+
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
41+
OUTPUT_FILE="${REPO_ROOT}/release/release-notes/data-prepper.change-log-${VERSION}.md"
42+
43+
git-release-notes "${PREVIOUS_VERSION}..${VERSION}" markdown > "$OUTPUT_FILE"
44+
45+
echo "Changelog written to $OUTPUT_FILE"

0 commit comments

Comments
 (0)