diff --git a/.github/actions/version-bump-pr/action.yml b/.github/actions/version-bump-pr/action.yml new file mode 100644 index 00000000..0970213a --- /dev/null +++ b/.github/actions/version-bump-pr/action.yml @@ -0,0 +1,67 @@ +name: Post release downstream version bump +description: Creates a version bump PR of repo tools in the specified downstream repo + +inputs: + repo: + description: Downstream repo name + required: true + version: + description: Repo tools version for pull request + required: true + pat: + description: A GitHub personal access token used to authenticate the requests in this action + required: true + +runs: + using: composite + steps: + - name: Checkout SDK + uses: actions/checkout@v4 + with: + repository: ${{ inputs.repo }} + path: ${{ inputs.repo }} + token: ${{ inputs.pat }} + + - name: Create pull request + shell: bash + env: + REPO: ${{ inputs.repo }} + NEW_VERSION: ${{ inputs.version }} + GH_TOKEN: ${{ inputs.pat }} + run: | + BRANCH=repo-tools-$NEW_VERSION + + cd $REPO + echo "Creating branch: $BRANCH" + git checkout -b $BRANCH + + echo "Configuring git" + git config user.name aws-sdk-kotlin-ci + git config user.email "aws-kotlin-sdk-automation@amazon.com" + + echo "Modifying version catalog to use repo tools $NEW_VERSION" + sed -i "s/aws-kotlin-repo-tools-version = .*/aws-kotlin-repo-tools-version = \"$NEW_VERSION\"/" gradle/libs.versions.toml + + echo "Modified version catalog:" + cat gradle/libs.versions.toml + + echo "Commiting modifications" + git add gradle/libs.versions.toml + git commit -m "misc: repo tools v$NEW_VERSION" + + echo "Pushing changes upstream" + git push --force --set-upstream origin $BRANCH + + EXISTING_PR=$(gh pr list --head "$BRANCH" --state open --json number -q '.[0].number') + + if [ -z "$EXISTING_PR" ]; then + echo "Creating pull request" + PR_URL=$(gh pr create --title "misc: repo tools v$NEW_VERSION" --body "Bumps repo tools to v$NEW_VERSION") + echo "Pull request created: $PR_URL" + + echo "Adding no-changelog label" + PR_NUMBER=$(basename $PR_URL) + gh pr edit $PR_NUMBER --add-label "no-changelog" + else + echo "::warning::Existing pull request found: $EXISTING_PR" + fi diff --git a/.github/workflows/run-release.yml b/.github/workflows/run-release.yml index ce98ea3f..46518ec2 100644 --- a/.github/workflows/run-release.yml +++ b/.github/workflows/run-release.yml @@ -7,11 +7,21 @@ on: type: string required: false description: 'Optionally specify a custom release version (minor version bump e.g.)' - kn-release: + sdk-version-bump: type: boolean required: false default: false - description: 'Whether the release is a KN variant of repo tools or not' + description: 'Whether to create an SDK version bump pull request for this release' + smithy-kotlin-version-bump: + type: boolean + required: false + default: false + description: 'Whether to create a Smithy Kotlin version bump pull request for this release' + crt-kotlin-version-bump: + type: boolean + required: false + default: false + description: 'Whether to create a CRT Kotlin version bump pull request for this release' permissions: id-token: write @@ -35,11 +45,7 @@ jobs: exit 0 fi - if [ "${{ inputs.kn-release }}" == "true" ]; then - CURRENT_VERSION=$(git tag --sort=-creatordate | grep -- '-kn$' | head -n 1) - else - CURRENT_VERSION=$(git tag --sort=-creatordate | grep -v -- '-kn$' | head -n 1) - fi + CURRENT_VERSION=$(git tag --sort=-creatordate | head -n 1) IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" PATCH_NUMBER=${PATCH%%[^0-9]*} @@ -63,12 +69,37 @@ jobs: aws-region: us-west-2 - name: Run codebuild release job + id: release-job uses: aws-actions/aws-codebuild-run-build@v1 with: project-name: publish-aws-kotlin-repo-tools source-version-override: ${{ steps.resolve-new-version.outputs.NEW_VERSION }} + - name: AWS SDK Kotlin pull request + if: ${{ inputs.sdk-version-bump == 'true' }} + uses: ./.github/actions/version-bump-pr + with: + repo: 'aws/aws-sdk-kotlin' + version: ${{ steps.resolve-new-version.outputs.NEW_VERSION }} + pat: ${{ secrets.CI_USER_PAT }} + + - name: Smithy Kotlin pull request + if: ${{ inputs.smithy-kotlin-version-bump == 'true' }} + uses: ./.github/actions/version-bump-pr + with: + repo: 'smithy-lang/smithy-kotlin' + version: ${{ steps.resolve-new-version.outputs.NEW_VERSION }} + pat: ${{ secrets.CI_USER_PAT }} + + - name: CRT Kotlin pull request + if: ${{ inputs.crt-kotlin-version-bump == 'true' }} + uses: ./.github/actions/version-bump-pr + with: + repo: 'aws/aws-crt-kotlin' + version: ${{ steps.resolve-new-version.outputs.NEW_VERSION }} + pat: ${{ secrets.CI_USER_PAT }} + - name: Delete failed release tag - if: ${{ failure() }} + if: ${{ failure() && steps.release-job.outcome != 'success' }} run: | git push --delete origin ${{ steps.resolve-new-version.outputs.NEW_VERSION }}