-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,117 @@ | ||
name: Pre Release Prepare - Update Version and Create PR | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version number (e.g., 1.0.1)' | ||
required: true | ||
default: '1.0.0' | ||
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 || '0.2.0' }}" >> $GITHUB_ENV | ||
echo "MAJOR_MINOR=$(echo ${{ github.event.inputs.version || '0.2.0' }} | 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="false" | ||
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/\"version\": \".*\"/\"version\": \"${VERSION}\"/" aws-distro-opentelemetry-node-autoinstrumentation/package.json | ||
sed -i'' -e "s/\"version\": \".*\"/\"version\": \"${VERSION}\"/" docker-utils/package.json | ||
sed -i'' -e "s/\"version\": \".*\"/\"version\": \"${VERSION}\"/" package.json | ||
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 || '0.2.0' }}_release \ | ||
--base release/v${MAJOR_MINOR}.x |