Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 42 additions & 14 deletions .github/workflows/post_release_version_bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ on:
version:
description: 'Version number (e.g., 1.0.1)'
required: true
is_patch:
description: 'Is this a patch? (true or false)'
required: true
default: 'false'

env:
AWS_DEFAULT_REGION: us-east-1
VERSION_INPUT: ${{ github.event.inputs.version }}
IS_PATCH_INPUT: ${{ github.event.inputs.is_patch }}

permissions:
id-token: write
Expand All @@ -20,15 +26,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
with:
ref: main
fetch-depth: 0

- name: Extract Major.Minor Version and setup Env variable
run: |
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
echo "MAJOR_MINOR=$(echo ${{ github.event.inputs.version }} | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_ENV
echo "VERSION=${{ env.VERSION_INPUT }}" >> $GITHUB_ENV
echo "MAJOR_MINOR=$(echo ${{ env.VERSION_INPUT }} | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_ENV

- name: Get current major.minor version from main branch
id: get_version
Expand Down Expand Up @@ -58,21 +64,21 @@ jobs:
needs: check-version
steps:
- name: Configure AWS credentials for BOT secrets
uses: aws-actions/configure-aws-credentials@v4
uses: aws-actions/configure-aws-credentials@a03048d87541d1d9fcf2ecf528a4a65ba9bd7838 #v5.0.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN_SECRETS_MANAGER }}
aws-region: ${{ env.AWS_DEFAULT_REGION }}

- name: Get Bot secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v1
uses: aws-actions/aws-secretsmanager-get-secrets@a9a7eb4e2f2871d30dc5b892576fde60a2ecc802 #v2.0.10
id: bot_secrets
with:
secret-ids: |
BOT_TOKEN ,${{ secrets.BOT_TOKEN_SECRET_ARN }}
parse-json-secrets: true

- name: Setup Git
uses: actions/checkout@v2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0
with:
fetch-depth: 0
token: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
Expand All @@ -84,8 +90,8 @@ jobs:

- name: Extract Major.Minor Version and setup Env variable
run: |
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
echo "MAJOR_MINOR=$(echo ${{ github.event.inputs.version }} | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_ENV
echo "VERSION=${{ env.VERSION_INPUT }}" >> $GITHUB_ENV
echo "MAJOR_MINOR=$(echo ${{ env.VERSION_INPUT }} | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_ENV

- name: Determine release branch and checkout
run: |
Expand All @@ -95,27 +101,49 @@ jobs:

- name: Update version to next development version in main
run: |
DEV_VERSION="${{ github.event.inputs.version }}.dev0"
DEV_VERSION="${{ env.VERSION_INPUT }}.dev0"
sed -i "s/public static string version = \".*\";/public static string version = \"${DEV_VERSION}\";/" src/AWS.Distro.OpenTelemetry.AutoInstrumentation/Version.cs
sed -i "s/private readonly string version = \".*\";/private readonly string version = \"${DEV_VERSION}\";/" build/Build.InstallationScripts.cs
VERSION="${{ github.event.inputs.version }}"
sed -i -e 's/dotnet:v.*"/dotnet:v'$VERSION'"/' .github/workflows/daily_scan.yml
VERSION="${{ env.VERSION_INPUT }}"
sed -i -e 's/dotnet:v.*"/dotnet:v'$VERSION'"/' .github/workflows/daily-scan.yml

# for patch releases, avoid merge conflict by manually resolving CHANGELOG with main
if [[ "${{ env.IS_PATCH_INPUT }}" == "true" ]]; then
# Copy the patch release entries
sed -n "/^## v${VERSION}/,/^## v[0-9]/p" CHANGELOG.md | sed '$d' > /tmp/patch_release_section.txt
git fetch origin main
git show origin/main:CHANGELOG.md > CHANGELOG.md
# Insert the patch release entries after Unreleased
awk -i inplace '/^## v[0-9]/ && !inserted { system("cat /tmp/patch_release_section.txt"); inserted=1 } {print}' CHANGELOG.md
fi

git add src/AWS.Distro.OpenTelemetry.AutoInstrumentation/Version.cs
git add build/Build.InstallationScripts.cs
git add .github/workflows/daily_scan.yml
git add .github/workflows/daily-scan.yml
git add CHANGELOG.md
git commit -m "Prepare main for next development cycle: Update version to $DEV_VERSION"
git push --set-upstream origin "prepare-main-for-next-dev-cycle-${VERSION}"

- name: Create Pull Request to main
env:
GITHUB_TOKEN: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
run: |
DEV_VERSION="${{ github.event.inputs.version }}.dev0"
DEV_VERSION="${{ env.VERSION_INPUT }}.dev0"
gh pr create --title "Post release $VERSION: Update version to $DEV_VERSION" \
--body "This PR prepares the main branch for the next development cycle by updating the version to $DEV_VERSION and updating the image version to be scanned to the latest released.

This PR should only be merge when release for version v$VERSION is success.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice." \
--head prepare-main-for-next-dev-cycle-${VERSION} \
--base main
--base main

- name: Force our CHANGELOG to override merge conflicts
run: |
git merge origin/main || true
git checkout --ours CHANGELOG.md
git add CHANGELOG.md
if ! git diff --quiet --cached; then
git commit -m "Force our CHANGELOG to override merge conflicts"
git push origin "prepare-main-for-next-dev-cycle-${VERSION}"
fi
10 changes: 6 additions & 4 deletions .github/workflows/pre_release_prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:

env:
AWS_DEFAULT_REGION: us-east-1
VERSION_INPUT: ${{ github.event.inputs.version }}
IS_PATCH_INPUT: ${{ github.event.inputs.is_patch }}

permissions:
contents: write
Expand Down Expand Up @@ -52,12 +54,12 @@ jobs:

- name: Extract Major.Minor Version and setup Env variable
run: |
echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
echo "MAJOR_MINOR=$(echo ${{ github.event.inputs.version }} | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_ENV
echo "VERSION=${{ env.VERSION_INPUT }}" >> $GITHUB_ENV
echo "MAJOR_MINOR=$(echo ${{ env.VERSION_INPUT }} | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_ENV

- name: Create branches
run: |
IS_PATCH=${{ github.event.inputs.is_patch }}
IS_PATCH=${{ env.IS_PATCH_INPUT }}
if [[ "$IS_PATCH" != "true" && "$IS_PATCH" != "false" ]]; then
echo "Invalid input for IS_PATCH. Must be 'true' or 'false'."
exit 1
Expand Down Expand Up @@ -103,5 +105,5 @@ jobs:
--body "This PR updates the version to ${VERSION}.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice." \
--head v${{ github.event.inputs.version }}_release \
--head v${{ env.VERSION_INPUT }}_release \
--base release/v${MAJOR_MINOR}.x
Loading
Loading