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+ env :
11+ AWS_DEFAULT_REGION : us-east-1
12+
13+ permissions :
14+ id-token : write
15+ contents : write
16+ pull-requests : write
17+
18+ jobs :
19+ check-version :
20+ runs-on : ubuntu-latest
21+ steps :
22+ - name : Checkout main
23+ uses : actions/checkout@v2
24+ with :
25+ ref : main
26+ fetch-depth : 0
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 : Get current major.minor version from main branch
34+ id : get_version
35+ run : |
36+ CURRENT_VERSION=$(grep '__version__' aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py | sed -E 's/__version__ = "([0-9]+\.[0-9]+)\.[0-9]+.*"/\1/')
37+ echo "CURRENT_MAJOR_MINOR_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
38+
39+ - name : Set major and minor for current version
40+ run : |
41+ echo "CURRENT_MAJOR=$(echo $CURRENT_MAJOR_MINOR_VERSION | cut -d. -f1)" >> $GITHUB_ENV
42+ echo "CURRENT_MINOR=$(echo $CURRENT_MAJOR_MINOR_VERSION | cut -d. -f2)" >> $GITHUB_ENV
43+
44+ - name : Set major and minor for input version
45+ run : |
46+ echo "INPUT_MAJOR=$(echo $MAJOR_MINOR | cut -d. -f1)" >> $GITHUB_ENV
47+ echo "INPUT_MINOR=$(echo $MAJOR_MINOR | cut -d. -f2)" >> $GITHUB_ENV
48+
49+ - name : Compare major.minor version and skip if behind
50+ run : |
51+ if [ "$CURRENT_MAJOR" -gt "$INPUT_MAJOR" ] || { [ "$CURRENT_MAJOR" -eq "$INPUT_MAJOR" ] && [ "$CURRENT_MINOR" -gt "$INPUT_MINOR" ]; }; then
52+ echo "Input version is behind main's current major.minor version, don't need to update major version"
53+ exit 1
54+ fi
55+
56+
57+ prepare-main :
58+ runs-on : ubuntu-latest
59+ needs : check-version
60+ steps :
61+ - name : Configure AWS credentials for BOT secrets
62+ uses : aws-actions/configure-aws-credentials@v4
63+ with :
64+ role-to-assume : ${{ secrets.AWS_ROLE_ARN_SECRETS_MANAGER }}
65+ aws-region : ${{ env.AWS_DEFAULT_REGION }}
66+
67+ - name : Get Bot secrets
68+ uses : aws-actions/aws-secretsmanager-get-secrets@v1
69+ id : bot_secrets
70+ with :
71+ secret-ids : |
72+ BOT_TOKEN ,${{ secrets.BOT_TOKEN_SECRET_ARN }}
73+ parse-json-secrets : true
74+
75+ - name : Setup Git
76+ uses : actions/checkout@v2
77+ with :
78+ fetch-depth : 0
79+ token : ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
80+
81+ - name : Configure Git
82+ run : |
83+ git config user.name "github-actions"
84+ git config user.email "[email protected] " 85+
86+ - name : Extract Major.Minor Version and setup Env variable
87+ run : |
88+ echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
89+ echo "MAJOR_MINOR=$(echo ${{ github.event.inputs.version }} | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_ENV
90+
91+ - name : Determine release branch and checkout
92+ run : |
93+ RELEASE_BRANCH="release/v${MAJOR_MINOR}.x"
94+ git fetch origin $RELEASE_BRANCH
95+ git checkout -b "prepare-main-for-next-dev-cycle-${VERSION}" origin/$RELEASE_BRANCH
96+
97+ - name : Update version to next development version in main
98+ run : |
99+ DEV_VERSION="${{ github.event.inputs.version }}.dev0"
100+ sed -i'' -e "s/val adotVersion = \".*\"/val adotVersion = \"${DEV_VERSION}\"/" version.gradle.kts
101+ VERSION="${{ github.event.inputs.version }}"
102+ sed -i'' -e 's/adot-autoinstrumentation-java:v2\.[0-9]+\.[0-9]+/adot-autoinstrumentation-java:v'$VERSION'/g' .github/workflows/daily-scan.yml
103+ git add version.gradle.kts
104+ git add .github/workflows/daily-scan.yml
105+ git commit -m "Prepare main for next development cycle: Update version to $DEV_VERSION"
106+ git push --set-upstream origin "prepare-main-for-next-dev-cycle-${VERSION}"
107+
108+ - name : Create Pull Request to main
109+ env :
110+ GITHUB_TOKEN : ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
111+ run : |
112+ DEV_VERSION="${{ github.event.inputs.version }}.dev0"
113+ gh pr create --title "Post release $VERSION: Update version to $DEV_VERSION" \
114+ --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.
115+
116+ This PR should only be merge when release for version v$VERSION is success.
117+
118+ By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice." \
119+ --head prepare-main-for-next-dev-cycle-${VERSION} \
120+ --base main
0 commit comments