Skip to content

Post Release - Prepare Main for Next Development Cycle #4

Post Release - Prepare Main for Next Development Cycle

Post Release - Prepare Main for Next Development Cycle #4

name: Post Release - Prepare Main for Next Development Cycle
on:
workflow_dispatch:
inputs:
version:
description: 'Version number (e.g., 1.0.1)'
required: true
permissions:
contents: write
pull-requests: write
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v2
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
- name: Get current major.minor version from main branch
id: get_version
run: |
CURRENT_VERSION=$(grep '__version__' aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py | sed -E 's/__version__ = "([0-9]+\.[0-9]+)\.[0-9]+.*"/\1/')
echo "CURRENT_MAJOR_MINOR_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
- name: Compare major.minor version and skip if behind
if: env.CURRENT_MAJOR_MINOR_VERSION < env.MAJOR_MINOR
run: |
echo "Input version behind main's current major.minor version, don't need to update major version"
exit 1
prepare-main:
runs-on: ubuntu-latest
needs: check-version
steps:
- name: Setup Git
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
- 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
- name: Determine release branch and checkout
run: |
RELEASE_BRANCH="release/${MAJOR_MINOR}.x"
git fetch origin $RELEASE_BRANCH
git checkout -b "prepare-main-for-next-dev-cycle-${VERSION}" origin/$RELEASE_BRANCH
- name: Update version to next development version in main
run: |
DEV_VERSION="${{ github.event.inputs.version }}.dev0"
sed -i 's/__version__ = ".*"/__version__ = "'$DEV_VERSION'"/' aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py
VERSION="${{ github.event.inputs.version }}"
sed -i 's/python:v.*"/python:v'$VERSION'"/' .github/workflows/released_image_scan.yml
git add aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py
git add .github/workflows/released_image_scan.yml
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: ${{ secrets.GITHUB_TOKEN }}
run: |
DEV_VERSION="${{ github.event.inputs.version }}.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