Skip to content

Commit be3bdcb

Browse files
authored
Create workflows for release prepare and post release cleanup (#119)
*Description of changes:* Create two workflow for release pre_release workflow: Create two branch 1.0.0_release and release/1.0.x, change the version to 1.0.0 in 1.0.0_release, PR to release/1.0.x post_release workflow: Checkout and create branch from release/1.0.x (named main_version_bump_1.0.0.dev0), change the version to 1.0.0.dev0 and PR to main Test result: As designed, see https://github.com/XinRanZhAWS/aws-otel-python-instrumentation/actions/runs/8381268165 https://github.com/XinRanZhAWS/aws-otel-python-instrumentation/actions/runs/8381278321 https://github.com/zzhlogin/aws-otel-python-instrumentation/actions/runs/8396454906 XinRanZhAWS/aws-otel-python-instrumentation#6 XinRanZhAWS/aws-otel-python-instrumentation#7 https://github.com/zzhlogin/aws-otel-python-instrumentation/pull/8 By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent f5302c9 commit be3bdcb

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Post Release - Prepare Main for Next Development Cycle
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version number (e.g., 1.0.1)'
8+
required: true
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
prepare-main:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Setup Git
19+
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Configure Git
24+
run: |
25+
git config user.name "github-actions"
26+
git config user.email "[email protected]"
27+
28+
- name: Extract Major.Minor Version and setup Env variable
29+
run: |
30+
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
31+
echo "MAJOR_MINOR=$(echo ${{ github.event.inputs.version }} | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_ENV
32+
33+
- name: Determine release branch and checkout
34+
run: |
35+
RELEASE_BRANCH="release/${MAJOR_MINOR}.x"
36+
git fetch origin $RELEASE_BRANCH
37+
git checkout -b "prepare-main-for-next-dev-cycle-${VERSION}" origin/$RELEASE_BRANCH
38+
39+
- name: Update version to next development version in main
40+
run: |
41+
DEV_VERSION="${{ github.event.inputs.version }}.dev0"
42+
sed -i 's/__version__ = ".*"/__version__ = "'$DEV_VERSION'"/' aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py
43+
git add aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py
44+
git commit -m "Prepare main for next development cycle: Update version to $DEV_VERSION"
45+
git push --set-upstream origin "prepare-main-for-next-dev-cycle-${VERSION}"
46+
47+
- name: Create Pull Request to main
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: |
51+
DEV_VERSION="${{ github.event.inputs.version }}.dev0"
52+
gh pr create --title "Post release $VERSION: Update version to $DEV_VERSION" \
53+
--body "This PR prepares the main branch for the next development cycle by updating the version to $DEV_VERSION.
54+
55+
This PR should only be merge when release for version v$VERSION is success.
56+
57+
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice." \
58+
--head prepare-main-for-next-dev-cycle-${VERSION} \
59+
--base main
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Pre Release Prepare - Update Version and Create PR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version number (e.g., 1.0.1)'
8+
required: true
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
15+
jobs:
16+
update-version-and-create-pr:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout main branch
20+
uses: actions/checkout@v3
21+
with:
22+
ref: 'main'
23+
24+
- name: Setup Git
25+
run: |
26+
git config user.name "github-actions"
27+
git config user.email "[email protected]"
28+
29+
- name: Extract Major.Minor Version and setup Env variable
30+
run: |
31+
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
32+
echo "MAJOR_MINOR=$(echo ${{ github.event.inputs.version }} | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_ENV
33+
34+
- name: Create branches
35+
run: |
36+
git checkout -b "release/${MAJOR_MINOR}.x"
37+
git push origin "release/${MAJOR_MINOR}.x"
38+
git checkout -b "${VERSION}_release"
39+
git push origin "${VERSION}_release"
40+
41+
- name: Update version in file
42+
run: |
43+
sed -i "s/__version__ = \".*\"/__version__ = \\\"${VERSION}\\\"/" aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py
44+
git commit -am "Update version to ${VERSION}"
45+
git push origin "${VERSION}_release"
46+
47+
- name: Create pull request against the release branch
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: |
51+
gh pr create --title "Pre-release: Update version to ${VERSION}" \
52+
--body "This PR updates the version to ${VERSION}.
53+
54+
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice." \
55+
--head ${{ github.event.inputs.version }}_release \
56+
--base release/${MAJOR_MINOR}.x

0 commit comments

Comments
 (0)