Skip to content

Commit 5850aa8

Browse files
authored
chore(ci): bump package version after release via pull request (#2239)
* chore: convert create-pr steps into composite action Signed-off-by: heitorlessa <[email protected]> * chore(ci): changelog to use new create-pr action Signed-off-by: heitorlessa <[email protected]> * chore(ci): revert changelog to trigger on push Signed-off-by: heitorlessa <[email protected]> * chore: document custom action Signed-off-by: heitorlessa <[email protected]> * chore: add support for any target branch Signed-off-by: heitorlessa <[email protected]> * chore: create a PR to bump version after release Signed-off-by: heitorlessa <[email protected]> * chore: write permission is no longer necessary Signed-off-by: heitorlessa <[email protected]> * chore: remove changelog from release * chore: address leandro's feedback Signed-off-by: Heitor Lessa <[email protected]> * chore: address leandro's feedback Signed-off-by: Heitor Lessa <[email protected]> --------- Signed-off-by: heitorlessa <[email protected]> Signed-off-by: Heitor Lessa <[email protected]>
1 parent b4b0137 commit 5850aa8

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

.github/workflows/release.yml

+23-24
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
build:
5252
runs-on: aws-lambda-powertools_ubuntu-latest_4-core
5353
permissions:
54-
contents: write
54+
contents: read
5555
outputs:
5656
RELEASE_VERSION: ${{ steps.release_version.outputs.RELEASE_VERSION }}
5757
env:
@@ -79,13 +79,6 @@ jobs:
7979
- name: Run all tests, linting and baselines
8080
if: ${{ !inputs.skip_code_quality }}
8181
run: make pr
82-
- name: Git client setup and refresh tip
83-
run: |
84-
git config user.name "Release bot"
85-
git config user.email "[email protected]"
86-
git config pull.rebase true
87-
git config remote.origin.url >&- || git remote add origin https://github.com/"${ORIGIN}" # Git Detached mode (release notes) doesn't have origin
88-
git pull origin "${BRANCH}"
8982
- name: Bump package version
9083
id: versioning
9184
run: poetry version "${RELEASE_VERSION}"
@@ -105,16 +98,6 @@ jobs:
10598
# and also future-proof for when we switch to protected branch and update via PR
10699
key: ${{ runner.os }}-${{ env.RELEASE_VERSION }}-${{ hashFiles('**/poetry.lock') }}
107100

108-
- name: Update version in trunk
109-
if: steps.versioning.outcome == 'success'
110-
run: |
111-
HAS_CHANGE=$(git status --porcelain)
112-
test -z "${HAS_CHANGE}" && echo "Nothing to update" && exit 0
113-
git add pyproject.toml
114-
git commit -m "bump version to ${RELEASE_VERSION}" --no-verify
115-
git pull origin "${BRANCH}" # prevents concurrent branch update failing push
116-
git push origin HEAD:refs/heads/"${BRANCH}"
117-
118101
release:
119102
needs: build
120103
environment: release
@@ -143,12 +126,6 @@ jobs:
143126
# with:
144127
# repository-url: https://test.pypi.org/legacy/
145128

146-
changelog:
147-
needs: release
148-
permissions:
149-
contents: write
150-
uses: ./.github/workflows/reusable_publish_changelog.yml
151-
152129
# NOTE: Watch out for the depth limit of 4 nested workflow_calls.
153130
# publish_layer -> publish_v2_layer -> reusable_deploy_v2_layer_stack -> reusable_update_v2_layer_arn_docs
154131
publish_layer:
@@ -163,6 +140,28 @@ jobs:
163140
latest_published_version: ${{ needs.build.outputs.RELEASE_VERSION }}
164141
pre_release: ${{ inputs.pre_release }}
165142

143+
bump_version:
144+
needs: [build, release]
145+
permissions:
146+
contents: write # create-pr action creates a temporary branch
147+
pull-requests: write # create-pr action creates a PR using the temporary branch
148+
runs-on: ubuntu-latest
149+
env:
150+
RELEASE_VERSION: ${{ needs.build.outputs.RELEASE_VERSION }}
151+
steps:
152+
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
153+
- name: Bump package version
154+
id: versioning
155+
run: poetry version "${RELEASE_VERSION}"
156+
- name: Create PR
157+
id: create-pr
158+
uses: ./.github/actions/create-pr
159+
with:
160+
files: "pyproject.toml"
161+
temp_branch_prefix: "ci-bump"
162+
pull_request_title: "chore(ci): bump version to ${{ env.RELEASE_VERSION }}"
163+
github_token: ${{ secrets.GITHUB_TOKEN }}
164+
166165
post_release:
167166
needs: [build, release, publish_layer]
168167
permissions:

0 commit comments

Comments
 (0)