-
Notifications
You must be signed in to change notification settings - Fork 65
Add pre-release and post-release workflows #1123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ezhang6811
wants to merge
4
commits into
aws-observability:main
Choose a base branch
from
ezhang6811:zhaez/release-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
name: Post Release - Prepare Main for Next Development Cycle | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version number (e.g., 1.0.1)' | ||
required: true | ||
|
||
env: | ||
AWS_DEFAULT_REGION: us-east-1 | ||
|
||
permissions: | ||
id-token: write | ||
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: Set major and minor for current version | ||
run: | | ||
echo "CURRENT_MAJOR=$(echo $CURRENT_MAJOR_MINOR_VERSION | cut -d. -f1)" >> $GITHUB_ENV | ||
echo "CURRENT_MINOR=$(echo $CURRENT_MAJOR_MINOR_VERSION | cut -d. -f2)" >> $GITHUB_ENV | ||
|
||
- name: Set major and minor for input version | ||
run: | | ||
echo "INPUT_MAJOR=$(echo $MAJOR_MINOR | cut -d. -f1)" >> $GITHUB_ENV | ||
echo "INPUT_MINOR=$(echo $MAJOR_MINOR | cut -d. -f2)" >> $GITHUB_ENV | ||
|
||
- name: Compare major.minor version and skip if behind | ||
run: | | ||
if [ "$CURRENT_MAJOR" -gt "$INPUT_MAJOR" ] || { [ "$CURRENT_MAJOR" -eq "$INPUT_MAJOR" ] && [ "$CURRENT_MINOR" -gt "$INPUT_MINOR" ]; }; then | ||
echo "Input version is behind main's current major.minor version, don't need to update major version" | ||
exit 1 | ||
fi | ||
|
||
|
||
prepare-main: | ||
runs-on: ubuntu-latest | ||
needs: check-version | ||
steps: | ||
- name: Configure AWS credentials for BOT secrets | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
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 | ||
id: bot_secrets | ||
with: | ||
secret-ids: | | ||
BOT_TOKEN ,${{ secrets.BOT_TOKEN_SECRET_ARN }} | ||
parse-json-secrets: true | ||
|
||
- name: Setup Git | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }} | ||
|
||
- name: Configure Git | ||
run: | | ||
git config user.name "github-actions" | ||
git config user.email "[email protected]" | ||
|
||
- 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/v${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'' -e "s/val adotVersion = \".*\"/val adotVersion = \"${DEV_VERSION}\"/" version.gradle.kts | ||
VERSION="${{ github.event.inputs.version }}" | ||
sed -i'' -e 's/adot-autoinstrumentation-java:v2.*"/adot-autoinstrumentation-java:v'$VERSION'"/' .github/workflows/daily-scan.yml | ||
git add version.gradle.kts | ||
git add .github/workflows/daily-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: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }} | ||
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
name: Pre Release Prepare - Update Version and Create PR | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
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 | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
id-token: write | ||
|
||
|
||
jobs: | ||
update-version-and-create-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Configure AWS credentials for BOT secrets | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
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 | ||
id: bot_secrets | ||
with: | ||
secret-ids: | | ||
BOT_TOKEN ,${{ secrets.BOT_TOKEN_SECRET_ARN }} | ||
parse-json-secrets: true | ||
|
||
- name: Checkout main branch | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: 'main' | ||
token: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }} | ||
|
||
- name: Setup Git | ||
run: | | ||
git config user.name "github-actions" | ||
git config user.email "[email protected]" | ||
|
||
- 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: Create branches | ||
run: | | ||
IS_PATCH=${{ github.event.inputs.is_patch }} | ||
if [[ "$IS_PATCH" != "true" && "$IS_PATCH" != "false" ]]; then | ||
echo "Invalid input for IS_PATCH. Must be 'true' or 'false'." | ||
exit 1 | ||
fi | ||
|
||
|
||
if git ls-remote --heads origin release/v${MAJOR_MINOR}.x | grep -q "release/v${MAJOR_MINOR}.x"; then | ||
if [ "$IS_PATCH" = "true" ]; then | ||
git fetch origin release/v${MAJOR_MINOR}.x | ||
echo "Branch release/v${MAJOR_MINOR}.x already exists, checking out." | ||
git checkout "release/v${MAJOR_MINOR}.x" | ||
else | ||
echo "Error, release series branch release/v${MAJOR_MINOR}.x exist for non-patch release" | ||
echo "Check your input or branch" | ||
exit 1 | ||
fi | ||
else | ||
if [ "$IS_PATCH" = "true" ]; then | ||
echo "Error, release series branch release/v${MAJOR_MINOR}.x NOT exist for patch release" | ||
echo "Check your input or branch" | ||
exit 1 | ||
else | ||
echo "Creating branch release/v${MAJOR_MINOR}.x." | ||
git checkout -b "release/v${MAJOR_MINOR}.x" | ||
git push origin "release/v${MAJOR_MINOR}.x" | ||
fi | ||
fi | ||
|
||
git checkout -b "v${VERSION}_release" | ||
git push origin "v${VERSION}_release" | ||
|
||
- name: Update version in file | ||
run: | | ||
sed -i'' -e "s/val adotVersion = \".*\"/val adotVersion = \"${VERSION}\"/" version.gradle.kts | ||
git commit -am "Update version to ${VERSION}" | ||
git push origin "v${VERSION}_release" | ||
|
||
- name: Create pull request against the release branch | ||
env: | ||
GITHUB_TOKEN: ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }} | ||
run: | | ||
gh pr create --title "Pre-release: Update version to ${VERSION}" \ | ||
--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 \ | ||
--base release/v${MAJOR_MINOR}.x |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.