From defe5e77ec38dfbdc4355150487b9285c038e3a6 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 11 May 2023 11:49:46 +0200 Subject: [PATCH 01/10] chore: convert create-pr steps into composite action Signed-off-by: heitorlessa --- .github/actions/create-pr/action.yml | 56 +++++++ .../create-pr/create_pr_for_staged_changes.sh | 145 ++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 .github/actions/create-pr/action.yml create mode 100755 .github/actions/create-pr/create_pr_for_staged_changes.sh diff --git a/.github/actions/create-pr/action.yml b/.github/actions/create-pr/action.yml new file mode 100644 index 00000000000..f3519273f25 --- /dev/null +++ b/.github/actions/create-pr/action.yml @@ -0,0 +1,56 @@ +name: "Create PR custom action" +description: "Create a PR and a temporary branch, close duplicates" + +# This custom action + +inputs: + files: + description: "Files to add" + required: true + temp_branch_prefix: + description: "Prefix for temporary git branch to be created, e.g, ci-docs" + required: true + pull_request_title: + description: "Pull Request title to use" + required: true + github_token: + description: "GitHub token for GitHub CLI" + required: true +outputs: + pull_request_id: + description: "Pull request ID created" + value: ${{ steps.create-pr.outputs.pull_request_id }} + temp_branch: + description: "Temporary branch created with staged changed" + value: ${{ steps.create-pr.outputs.temp_branch }} +runs: + using: "composite" + steps: + - id: adjust-path + run: echo "${{ github.action_path }}" >> $GITHUB_PATH + shell: bash + - id: setup-git + name: Git client setup and refresh tip + run: | + git config user.name "Powertools bot" + git config user.email "aws-lambda-powertools-feedback@amazon.com" + git config pull.rebase true + git config remote.origin.url >&- + shell: bash + - id: create-pr + working-directory: ${{ env.GITHUB_WORKSPACE }} + run: create_pr_for_staged_changes.sh "${FILES}" + env: + FILES: ${{ inputs.files }} + TEMP_BRANCH_PREFIX: ${{ inputs.temp_branch_prefix }} + GH_TOKEN: ${{ inputs.github_token }} + PR_TITLE: ${{ inputs.pull_request_title }} + shell: bash + - id: cleanup + name: Cleanup orphaned branch + if: failure() + run: git push origin --delete "${TEMP_BRANCH_PREFIX}-${GITHUB_RUN_ID}" || echo "Must have failed before creating temporary branch; no cleanup needed." + env: + TEMP_BRANCH_PREFIX: ${{ inputs.temp_branch_prefix }} + GITHUB_RUN_ID: ${{ github.run_id }} + shell: bash diff --git a/.github/actions/create-pr/create_pr_for_staged_changes.sh b/.github/actions/create-pr/create_pr_for_staged_changes.sh new file mode 100755 index 00000000000..2f32ab24342 --- /dev/null +++ b/.github/actions/create-pr/create_pr_for_staged_changes.sh @@ -0,0 +1,145 @@ +#!/bin/bash +set -uo pipefail # prevent accessing unset env vars, prevent masking pipeline errors to the next command + +#docs +#title :create_pr_for_staged_changes.sh +#description :This script will create a PR for staged changes, detect and close duplicate PRs. +#author :@heitorlessa +#date :May 8th 2023 +#version :0.1 +#usage :bash create_pr_for_staged_changes.sh {git_staged_files_or_directories_separated_by_space} +#notes :Meant to use in GitHub Actions only. Temporary branch will be named $TEMP_BRANCH_PREFIX-$GITHUB_RUN_ID +#os_version :Ubuntu 22.04.2 LTS +#required_env_vars :PR_TITLE, TEMP_BRANCH_PREFIX, GH_TOKEN +#============================================================================== + +# Sets GitHub Action with error message to ease troubleshooting +function error() { + echo "::error file=${FILENAME}::$1" + exit 1 +} + +function debug() { + TIMESTAMP=$(date -u "+%FT%TZ") # 2023-05-10T07:53:59Z + echo ""${TIMESTAMP}" - $1" +} + +function notice() { + echo "::notice file=${FILENAME}::$1" +} + +function start_span() { + echo "::group::$1" +} + +function end_span() { + echo "::endgroup::" +} + +function has_required_config() { + start_span "Validating required config" + test -z "${TEMP_BRANCH_PREFIX}" && error "TEMP_BRANCH_PREFIX env must be set to create a PR" + test -z "${PR_TITLE}" && error "PR_TITLE env must be set" + test -z "${GH_TOKEN}" && error "GH_TOKEN env must be set for GitHub CLI" + + # Default GitHub Actions Env Vars: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables + debug "Are we running in GitHub Action environment?" + test -z "${GITHUB_RUN_ID}" && error "GITHUB_RUN_ID env must be set to trace Workflow Run ID back to PR" + test -z "${GITHUB_SERVER_URL}" && error "GITHUB_SERVER_URL env must be set to trace Workflow Run ID back to PR" + test -z "${GITHUB_REPOSITORY}" && error "GITHUB_REPOSITORY env must be set to trace Workflow Run ID back to PR" + + debug "Config validated successfully!" + set_environment_variables + end_span +} + +function set_environment_variables() { + start_span "Setting environment variables" + export readonly WORKFLOW_URL="${GITHUB_SERVER_URL}"/"${GITHUB_REPOSITORY}"/actions/runs/"${GITHUB_RUN_ID}" # e.g., heitorlessa/aws-lambda-powertools-test/actions/runs/4913570678 + export readonly TEMP_BRANCH="${TEMP_BRANCH_PREFIX}"-"${GITHUB_RUN_ID}" # e.g., ci-changelog-4894658712 + export readonly BASE_BRANCH="${BASE_BRANCH:-develop}" # e.g., main, defaults to develop if missing + export readonly PR_BODY="This is an automated PR created from the following workflow" + export readonly FILENAME=".github/scripts/$(basename "$0")" + export readonly NO_DUPLICATES_MESSAGE="No duplicated PRs found" + end_span +} + +function has_anything_changed() { + start_span "Validating git staged files" + HAS_ANY_SOURCE_CODE_CHANGED="$(git status --porcelain)" + + test -z "${HAS_ANY_SOURCE_CODE_CHANGED}" && debug "Nothing to update; exitting early" && exit 0 + end_span +} + +function create_temporary_branch_with_changes() { + start_span "Creating temporary branch: "${TEMP_BRANCH}"" + git checkout -b "${TEMP_BRANCH}" + + debug "Committing staged files: $*" + echo "$@" | xargs -n1 git add || error "Failed to add staged changes: "$@"" + git commit -m "${PR_TITLE}" + + git push origin "${TEMP_BRANCH}" + end_span +} + +function create_pr() { + start_span "Creating PR against ${TEMP_BRANCH} branch" + NEW_PR_URL=$(gh pr create --title "${PR_TITLE}" --body "${PR_BODY}: ${WORKFLOW_URL}" --base "${BASE_BRANCH}" || error "Failed to create PR") # e.g, https://github.com/awslabs/aws-lambda-powertools/pull/13 + + # greedy remove any string until the last URL path, including the last '/'. https://opensource.com/article/17/6/bash-parameter-expansion + debug "Extracing PR Number from PR URL: "${NEW_PR_URL}"" + NEW_PR_ID="${NEW_PR_URL##*/}" # 13 + export NEW_PR_URL + export NEW_PR_ID + end_span +} + +function close_duplicate_prs() { + start_span "Searching for duplicate PRs" + DUPLICATE_PRS=$(gh pr list --search "${PR_TITLE}" --json number --jq ".[] | select(.number != ${NEW_PR_ID}) | .number") # e.g, 13\n14 + + if [ -z "${DUPLICATE_PRS}" ]; then + debug "No duplicate PRs found" + DUPLICATE_PRS="${NO_DUPLICATES_MESSAGE}" + else + debug "Closing duplicated PRs: "${DUPLICATE_PRS}"" + echo "${DUPLICATE_PRS}" | xargs -L1 gh pr close --delete-branch --comment "Superseded by #${NEW_PR_ID}" + fi + + export readonly DUPLICATE_PRS + end_span +} + +function report_job_output() { + start_span "Updating job outputs" + echo pull_request_id="${NEW_PR_ID}" >>"$GITHUB_OUTPUT" + echo temp_branch="${TEMP_BRANCH}" >>"$GITHUB_OUTPUT" + end_span +} + +function report_summary() { + start_span "Creating job summary" + echo "### Pull request created successfully :rocket: ${NEW_PR_URL}

Closed duplicated PRs: ${DUPLICATE_PRS}" >>"$GITHUB_STEP_SUMMARY" + + notice "PR_URL is: ${NEW_PR_URL}" + notice "PR_BRANCH is: ${TEMP_BRANCH}" + notice "PR_DUPLICATES are: ${DUPLICATE_PRS}" + end_span +} + +function main() { + # Sanity check + has_anything_changed + has_required_config + + create_temporary_branch_with_changes "$@" + create_pr + close_duplicate_prs + + report_job_output + report_summary +} + +main "$@" From b36dea7ff1ac722a9c942537a0e0dfcdcb819dc7 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 11 May 2023 11:54:56 +0200 Subject: [PATCH 02/10] chore(ci): changelog to use new create-pr action Signed-off-by: heitorlessa --- .../scripts/create_pr_for_staged_changes.sh | 116 ------------------ .../workflows/reusable_publish_changelog.yml | 30 ++--- 2 files changed, 10 insertions(+), 136 deletions(-) delete mode 100644 .github/scripts/create_pr_for_staged_changes.sh diff --git a/.github/scripts/create_pr_for_staged_changes.sh b/.github/scripts/create_pr_for_staged_changes.sh deleted file mode 100644 index a35d45cc9e9..00000000000 --- a/.github/scripts/create_pr_for_staged_changes.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -set -uxo pipefail # enable debugging, prevent accessing unset env vars, prevent masking pipeline errors to the next command - -#docs -#title :create_pr_for_staged_changes.sh -#description :This script will create a PR for staged changes and detect and close duplicate PRs. -#author :@heitorlessa -#date :May 8th 2023 -#version :0.1 -#usage :bash create_pr_for_staged_changes.sh {git_staged_files_or_directories_separated_by_space} -#notes :Meant to use in GitHub Actions only. Temporary branch will be named $TEMP_BRANCH_PREFIX-$GITHUB_RUN_ID -#os_version :Ubuntu 22.04.2 LTS -#required_env_vars :COMMIT_MSG, PR_TITLE, TEMP_BRANCH_PREFIX, GH_TOKEN, GITHUB_RUN_ID, GITHUB_SERVER_URL, GITHUB_REPOSITORY -#============================================================================== - -PR_BODY="This is an automated PR created from the following workflow" -FILENAME=".github/scripts/$(basename "$0")" -readonly PR_BODY -readonly FILENAME - -# Sets GitHub Action with error message to ease troubleshooting -function raise_validation_error() { - echo "::error file=${FILENAME}::$1" - exit 1 -} - -function debug() { - echo "::debug::$1" -} - -function notice() { - echo "::notice file=${FILENAME}::$1" -} - -function has_required_config() { - # Default GitHub Actions Env Vars: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables - debug "Do we have required environment variables?" - test -z "${TEMP_BRANCH_PREFIX}" && raise_validation_error "TEMP_BRANCH_PREFIX env must be set to create a PR" - test -z "${GH_TOKEN}" && raise_validation_error "GH_TOKEN env must be set for GitHub CLI" - test -z "${COMMIT_MSG}" && raise_validation_error "COMMIT_MSG env must be set" - test -z "${PR_TITLE}" && raise_validation_error "PR_TITLE env must be set" - test -z "${GITHUB_RUN_ID}" && raise_validation_error "GITHUB_RUN_ID env must be set to trace Workflow Run ID back to PR" - test -z "${GITHUB_SERVER_URL}" && raise_validation_error "GITHUB_SERVER_URL env must be set to trace Workflow Run ID back to PR" - test -z "${GITHUB_REPOSITORY}" && raise_validation_error "GITHUB_REPOSITORY env must be set to trace Workflow Run ID back to PR" - - set_environment_variables -} - -function set_environment_variables() { - WORKFLOW_URL="${GITHUB_SERVER_URL}"/"${GITHUB_REPOSITORY}"/actions/runs/"${GITHUB_RUN_ID}" # e.g., heitorlessa/aws-lambda-powertools-test/actions/runs/4913570678 - TEMP_BRANCH="${TEMP_BRANCH_PREFIX}"-"${GITHUB_RUN_ID}" # e.g., ci-changelog-4894658712 - - export readonly WORKFLOW_URL - export readonly TEMP_BRANCH -} - -function has_anything_changed() { - debug "Is there an update to the source code?" - HAS_ANY_SOURCE_CODE_CHANGED="$(git status --porcelain)" - - test -z "${HAS_ANY_SOURCE_CODE_CHANGED}" && echo "Nothing to update" && exit 0 -} - -function create_temporary_branch_with_changes() { - debug "Creating branch ${TEMP_BRANCH}" - git checkout -b "${TEMP_BRANCH}" - - debug "Committing staged files: $*" - git add "$@" - git commit -m "${COMMIT_MSG}" - - debug "Creating branch remotely" - git push origin "${TEMP_BRANCH}" -} - -function create_pr() { - debug "Creating PR against ${BRANCH} branch" - NEW_PR_URL=$(gh pr create --title "${PR_TITLE}" --body "${PR_BODY}: ${WORKFLOW_URL}" --base "${BRANCH}") # e.g, https://github.com/awslabs/aws-lambda-powertools/pull/13 - - # greedy remove any string until the last URL path, including the last '/'. https://opensource.com/article/17/6/bash-parameter-expansion - NEW_PR_ID="${NEW_PR_URL##*/}" # 13 - export NEW_PR_URL - export NEW_PR_ID -} - -function close_duplicate_prs() { - debug "Do we have any duplicate PRs?" - DUPLICATE_PRS=$(gh pr list --search "${PR_TITLE}" --json number --jq ".[] | select(.number != ${NEW_PR_ID}) | .number") # e.g, 13\n14 - - debug "Closing duplicated PRs if any" - echo "${DUPLICATE_PRS}" | xargs -L1 gh pr close --delete-branch --comment "Superseded by #${NEW_PR_ID}" - export readonly DUPLICATE_PRS -} - -function report_summary() { - debug "Creating job summary" - echo "### Pull request created successfully :rocket: #${NEW_PR_URL}

Closed duplicated PRs (if any): ${DUPLICATE_PRS}" >>"$GITHUB_STEP_SUMMARY" - - notice "PR_URL is ${NEW_PR_URL}" - notice "PR_BRANCH is ${TEMP_BRANCH}" - notice "PR_DUPLICATES are ${DUPLICATE_PRS}" -} - -function main() { - # Sanity check - has_anything_changed - has_required_config - - create_temporary_branch_with_changes "$@" - create_pr - close_duplicate_prs - - report_summary -} - -main "$@" diff --git a/.github/workflows/reusable_publish_changelog.yml b/.github/workflows/reusable_publish_changelog.yml index 4294dda4a94..f08b23ca9f1 100644 --- a/.github/workflows/reusable_publish_changelog.yml +++ b/.github/workflows/reusable_publish_changelog.yml @@ -4,7 +4,9 @@ on: workflow_call: env: - BRANCH: develop + TEMP_BRANCH_PREFIX: "ci-changelog" + PULL_REQUEST_TITLE: "chore(ci): changelog rebuild" + FILES_TO_COMMIT: "CHANGELOG.md" jobs: publish_changelog: @@ -21,25 +23,13 @@ jobs: uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 with: fetch-depth: 0 - - name: Git client setup and refresh tip - run: | - git config user.name "Release bot" - git config user.email "aws-devax-open-source@amazon.com" - git config pull.rebase true - git config remote.origin.url >&- || git remote add origin https://github.com/"${origin}" # Git Detached mode (release notes) doesn't have origin - git pull origin "${BRANCH}" - name: "Generate latest changelog" run: make changelog - name: Create PR - run: bash .github/scripts/create_pr_for_staged_changes.sh CHANGELOG.md - env: - COMMIT_MSG: "chore(ci): update changelog with latest changes" - PR_TITLE: "chore(ci): changelog rebuild" - TEMP_BRANCH_PREFIX: "ci-changelog" - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Cleanup orphaned branch - if: failure() - run: git push origin --delete "${TEMP_BRANCH_PREFIX}-${GITHUB_RUN_ID}" || echo "Must have failed before creating temporary branch; no cleanup needed." - env: - TEMP_BRANCH_PREFIX: "ci-changelog" - GITHUB_RUN_ID: ${{ github.run_id }} + id: create-pr + uses: ./.github/actions/create-pr + with: + files: ${{ env.FILES_TO_COMMIT }} + temp_branch_prefix: ${{ env.TEMP_BRANCH_PREFIX }} + pull_request_title: ${{ env.PULL_REQUEST_TITLE }} + github_token: ${{ secrets.GITHUB_TOKEN }} From 2ca2f0e6635b5bcf761285dbf1e6238b036d82d3 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 11 May 2023 11:55:51 +0200 Subject: [PATCH 03/10] chore(ci): revert changelog to trigger on push Signed-off-by: heitorlessa --- .github/workflows/build_changelog.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_changelog.yml b/.github/workflows/build_changelog.yml index ebc978022bc..f15275d07a7 100644 --- a/.github/workflows/build_changelog.yml +++ b/.github/workflows/build_changelog.yml @@ -3,17 +3,9 @@ name: Build changelog on: workflow_dispatch: - schedule: - # ┌───────────── minute (0 - 59) - # │ ┌───────────── hour (0 - 23) - # │ │ ┌───────────── day of the month (1 - 31) - # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) - # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) - # │ │ │ │ │ - # │ │ │ │ │ - # │ │ │ │ │ - # * * * * * - - cron: '0 8 * * *' + push: + branches: + - develop jobs: changelog: From 3905a4c9587e37ae8385082db2a5fc7fb63a0857 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 11 May 2023 12:04:27 +0200 Subject: [PATCH 04/10] chore: document custom action Signed-off-by: heitorlessa --- .github/actions/create-pr/action.yml | 29 ++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/actions/create-pr/action.yml b/.github/actions/create-pr/action.yml index f3519273f25..81d371b2882 100644 --- a/.github/actions/create-pr/action.yml +++ b/.github/actions/create-pr/action.yml @@ -1,11 +1,36 @@ name: "Create PR custom action" description: "Create a PR and a temporary branch, close duplicates" -# This custom action +# PROCESS +# +# 1. Setup git client using Powertools bot username +# 2. Pushes staged files to a temporary branch +# 3. Creates a PR from temporary branch against a target branch (typically trunk: develop, main, etc.) +# 4. Searches for duplicate PRs with the same title +# 5. If duplicates are found, link to the most recent one, close and delete their branches so we keep a single PR +# 6. In the event of failure, we delete the now orphaned branch (if any), and propagate the failure + +# USAGE +# +# - name: Create PR +# id: create-pr +# uses: ./.github/actions/create-pr +# with: +# files: "CHANGELOG.md" +# temp_branch_prefix: "ci-changelog" +# pull_request_title: "chore(ci): changelog rebuild" +# github_token: ${{ secrets.GITHUB_TOKEN }} +# - name: Step to demonstrate how to access outputs (no need for this) +# run: | +# echo "PR number: ${PR_ID}" +# echo "Branch: ${BRANCH}" +# env: +# PR_ID: ${{ steps.create-pr.outputs.pull_request_id}} +# BRANCH: ${{ steps.create-pr.outputs.temp_branch}} inputs: files: - description: "Files to add" + description: "Files to add separated by space" required: true temp_branch_prefix: description: "Prefix for temporary git branch to be created, e.g, ci-docs" From 0d53e16bfa820e6368c0029e9d858685d036cd62 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 11 May 2023 12:08:12 +0200 Subject: [PATCH 05/10] chore: add support for any target branch Signed-off-by: heitorlessa --- .github/actions/create-pr/action.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/actions/create-pr/action.yml b/.github/actions/create-pr/action.yml index 81d371b2882..b7713a6c785 100644 --- a/.github/actions/create-pr/action.yml +++ b/.github/actions/create-pr/action.yml @@ -41,6 +41,11 @@ inputs: github_token: description: "GitHub token for GitHub CLI" required: true + target_branch: + description: "Branch to target when creating a PR against (develop, by default)" + required: false + default: develop + outputs: pull_request_id: description: "Pull request ID created" @@ -48,6 +53,7 @@ outputs: temp_branch: description: "Temporary branch created with staged changed" value: ${{ steps.create-pr.outputs.temp_branch }} + runs: using: "composite" steps: @@ -68,8 +74,9 @@ runs: env: FILES: ${{ inputs.files }} TEMP_BRANCH_PREFIX: ${{ inputs.temp_branch_prefix }} - GH_TOKEN: ${{ inputs.github_token }} PR_TITLE: ${{ inputs.pull_request_title }} + BASE_BRANCH: ${{ inputs.target_branch }} + GH_TOKEN: ${{ inputs.github_token }} shell: bash - id: cleanup name: Cleanup orphaned branch From e3916108639bab9ef4271a8dcf002ac1cd7b4e5b Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 11 May 2023 15:12:09 +0200 Subject: [PATCH 06/10] chore: create a PR to bump version after release Signed-off-by: heitorlessa --- .github/workflows/release.yml | 39 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 38aadc4d873..d92a10caf30 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,13 +79,6 @@ jobs: - name: Run all tests, linting and baselines if: ${{ !inputs.skip_code_quality }} run: make pr - - name: Git client setup and refresh tip - run: | - git config user.name "Release bot" - git config user.email "aws-devax-open-source@amazon.com" - git config pull.rebase true - git config remote.origin.url >&- || git remote add origin https://github.com/"${ORIGIN}" # Git Detached mode (release notes) doesn't have origin - git pull origin "${BRANCH}" - name: Bump package version id: versioning run: poetry version "${RELEASE_VERSION}" @@ -105,16 +98,6 @@ jobs: # and also future-proof for when we switch to protected branch and update via PR key: ${{ runner.os }}-${{ env.RELEASE_VERSION }}-${{ hashFiles('**/poetry.lock') }} - - name: Update version in trunk - if: steps.versioning.outcome == 'success' - run: | - HAS_CHANGE=$(git status --porcelain) - test -z "${HAS_CHANGE}" && echo "Nothing to update" && exit 0 - git add pyproject.toml - git commit -m "bump version to ${RELEASE_VERSION}" --no-verify - git pull origin "${BRANCH}" # prevents concurrent branch update failing push - git push origin HEAD:refs/heads/"${BRANCH}" - release: needs: build environment: release @@ -163,6 +146,28 @@ jobs: latest_published_version: ${{ needs.build.outputs.RELEASE_VERSION }} pre_release: ${{ inputs.pre_release }} + bump_version: + needs: [build, release] + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + env: + RELEASE_VERSION: ${{ needs.build.outputs.RELEASE_VERSION }} + steps: + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: Bump package version + id: versioning + run: poetry version "${RELEASE_VERSION}" + - name: Create PR + id: create-pr + uses: ./.github/actions/create-pr + with: + files: "pyproject.toml" + temp_branch_prefix: "ci-bump" + pull_request_title: "chore(ci): bump version to ${{ env.RELEASE_VERSION }}" + github_token: ${{ secrets.GITHUB_TOKEN }} + post_release: needs: [build, release, publish_layer] permissions: From 5347f6423aeeb8913f38b37af4d3206921966ea8 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 11 May 2023 15:15:13 +0200 Subject: [PATCH 07/10] chore: write permission is no longer necessary Signed-off-by: heitorlessa --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d92a10caf30..b2d32a8264e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,7 +51,7 @@ jobs: build: runs-on: aws-lambda-powertools_ubuntu-latest_4-core permissions: - contents: write + contents: read outputs: RELEASE_VERSION: ${{ steps.release_version.outputs.RELEASE_VERSION }} env: From f847b85eed5c8bbf012e790821c81cfdd533b6c3 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 11 May 2023 16:49:54 +0200 Subject: [PATCH 08/10] chore: remove changelog from release --- .github/workflows/release.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b2d32a8264e..8c0caec90ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -126,12 +126,6 @@ jobs: # with: # repository-url: https://test.pypi.org/legacy/ - changelog: - needs: release - permissions: - contents: write - uses: ./.github/workflows/reusable_publish_changelog.yml - # NOTE: Watch out for the depth limit of 4 nested workflow_calls. # publish_layer -> publish_v2_layer -> reusable_deploy_v2_layer_stack -> reusable_update_v2_layer_arn_docs publish_layer: From 3649b0f54dbeeca17db987edce751274dbbb5cf7 Mon Sep 17 00:00:00 2001 From: Heitor Lessa Date: Fri, 12 May 2023 15:29:55 +0200 Subject: [PATCH 09/10] chore: address leandro's feedback Signed-off-by: Heitor Lessa --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8c0caec90ad..c73a68072cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -143,7 +143,7 @@ jobs: bump_version: needs: [build, release] permissions: - contents: write + contents: write # create-pr action creates a temporary branch pull-requests: write runs-on: ubuntu-latest env: From 67a35f6e0a3429c64725996ecc2e04f4635928ac Mon Sep 17 00:00:00 2001 From: Heitor Lessa Date: Fri, 12 May 2023 15:30:10 +0200 Subject: [PATCH 10/10] chore: address leandro's feedback Signed-off-by: Heitor Lessa --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c73a68072cc..f062baa01b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -144,7 +144,7 @@ jobs: needs: [build, release] permissions: contents: write # create-pr action creates a temporary branch - pull-requests: write + pull-requests: write # create-pr action creates a PR using the temporary branch runs-on: ubuntu-latest env: RELEASE_VERSION: ${{ needs.build.outputs.RELEASE_VERSION }}