Skip to content

Commit 825d70a

Browse files
authored
feat: automatic repo tools version bumps (#158)
1 parent c77a2c5 commit 825d70a

File tree

2 files changed

+106
-8
lines changed

2 files changed

+106
-8
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Post release downstream version bump
2+
description: Creates a version bump PR of repo tools in the specified downstream repo
3+
4+
inputs:
5+
repo:
6+
description: Downstream repo name
7+
required: true
8+
version:
9+
description: Repo tools version for pull request
10+
required: true
11+
pat:
12+
description: A GitHub personal access token used to authenticate the requests in this action
13+
required: true
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Checkout SDK
19+
uses: actions/checkout@v4
20+
with:
21+
repository: ${{ inputs.repo }}
22+
path: ${{ inputs.repo }}
23+
token: ${{ inputs.pat }}
24+
25+
- name: Create pull request
26+
shell: bash
27+
env:
28+
REPO: ${{ inputs.repo }}
29+
NEW_VERSION: ${{ inputs.version }}
30+
GH_TOKEN: ${{ inputs.pat }}
31+
run: |
32+
BRANCH=repo-tools-$NEW_VERSION
33+
34+
cd $REPO
35+
echo "Creating branch: $BRANCH"
36+
git checkout -b $BRANCH
37+
38+
echo "Configuring git"
39+
git config user.name aws-sdk-kotlin-ci
40+
git config user.email "[email protected]"
41+
42+
echo "Modifying version catalog to use repo tools $NEW_VERSION"
43+
sed -i "s/aws-kotlin-repo-tools-version = .*/aws-kotlin-repo-tools-version = \"$NEW_VERSION\"/" gradle/libs.versions.toml
44+
45+
echo "Modified version catalog:"
46+
cat gradle/libs.versions.toml
47+
48+
echo "Commiting modifications"
49+
git add gradle/libs.versions.toml
50+
git commit -m "misc: repo tools v$NEW_VERSION"
51+
52+
echo "Pushing changes upstream"
53+
git push --force --set-upstream origin $BRANCH
54+
55+
EXISTING_PR=$(gh pr list --head "$BRANCH" --state open --json number -q '.[0].number')
56+
57+
if [ -z "$EXISTING_PR" ]; then
58+
echo "Creating pull request"
59+
PR_URL=$(gh pr create --title "misc: repo tools v$NEW_VERSION" --body "Bumps repo tools to v$NEW_VERSION")
60+
echo "Pull request created: $PR_URL"
61+
62+
echo "Adding no-changelog label"
63+
PR_NUMBER=$(basename $PR_URL)
64+
gh pr edit $PR_NUMBER --add-label "no-changelog"
65+
else
66+
echo "::warning::Existing pull request found: $EXISTING_PR"
67+
fi

.github/workflows/run-release.yml

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@ on:
77
type: string
88
required: false
99
description: 'Optionally specify a custom release version (minor version bump e.g.)'
10-
kn-release:
10+
sdk-version-bump:
1111
type: boolean
1212
required: false
1313
default: false
14-
description: 'Whether the release is a KN variant of repo tools or not'
14+
description: 'Whether to create an SDK version bump pull request for this release'
15+
smithy-kotlin-version-bump:
16+
type: boolean
17+
required: false
18+
default: false
19+
description: 'Whether to create a Smithy Kotlin version bump pull request for this release'
20+
crt-kotlin-version-bump:
21+
type: boolean
22+
required: false
23+
default: false
24+
description: 'Whether to create a CRT Kotlin version bump pull request for this release'
1525

1626
permissions:
1727
id-token: write
@@ -35,11 +45,7 @@ jobs:
3545
exit 0
3646
fi
3747
38-
if [ "${{ inputs.kn-release }}" == "true" ]; then
39-
CURRENT_VERSION=$(git tag --sort=-creatordate | grep -- '-kn$' | head -n 1)
40-
else
41-
CURRENT_VERSION=$(git tag --sort=-creatordate | grep -v -- '-kn$' | head -n 1)
42-
fi
48+
CURRENT_VERSION=$(git tag --sort=-creatordate | head -n 1)
4349
4450
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
4551
PATCH_NUMBER=${PATCH%%[^0-9]*}
@@ -63,12 +69,37 @@ jobs:
6369
aws-region: us-west-2
6470

6571
- name: Run codebuild release job
72+
id: release-job
6673
uses: aws-actions/aws-codebuild-run-build@v1
6774
with:
6875
project-name: publish-aws-kotlin-repo-tools
6976
source-version-override: ${{ steps.resolve-new-version.outputs.NEW_VERSION }}
7077

78+
- name: AWS SDK Kotlin pull request
79+
if: ${{ inputs.sdk-version-bump == 'true' }}
80+
uses: ./.github/actions/version-bump-pr
81+
with:
82+
repo: 'aws/aws-sdk-kotlin'
83+
version: ${{ steps.resolve-new-version.outputs.NEW_VERSION }}
84+
pat: ${{ secrets.CI_USER_PAT }}
85+
86+
- name: Smithy Kotlin pull request
87+
if: ${{ inputs.smithy-kotlin-version-bump == 'true' }}
88+
uses: ./.github/actions/version-bump-pr
89+
with:
90+
repo: 'smithy-lang/smithy-kotlin'
91+
version: ${{ steps.resolve-new-version.outputs.NEW_VERSION }}
92+
pat: ${{ secrets.CI_USER_PAT }}
93+
94+
- name: CRT Kotlin pull request
95+
if: ${{ inputs.crt-kotlin-version-bump == 'true' }}
96+
uses: ./.github/actions/version-bump-pr
97+
with:
98+
repo: 'aws/aws-crt-kotlin'
99+
version: ${{ steps.resolve-new-version.outputs.NEW_VERSION }}
100+
pat: ${{ secrets.CI_USER_PAT }}
101+
71102
- name: Delete failed release tag
72-
if: ${{ failure() }}
103+
if: ${{ failure() && steps.release-job.outcome != 'success' }}
73104
run: |
74105
git push --delete origin ${{ steps.resolve-new-version.outputs.NEW_VERSION }}

0 commit comments

Comments
 (0)