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 'public final String VERSION' awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/ArtifactVersion.java | sed -E 's/ public final String 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+ prepare-main :
57+ runs-on : ubuntu-latest
58+ needs : check-version
59+ steps :
60+ - name : Configure AWS credentials for BOT secrets
61+ uses : aws-actions/configure-aws-credentials@v4
62+ with :
63+ role-to-assume : ${{ secrets.AWS_ROLE_ARN_SECRETS_MANAGER }}
64+ aws-region : ${{ env.AWS_DEFAULT_REGION }}
65+
66+ - name : Get Bot secrets
67+ uses : aws-actions/aws-secretsmanager-get-secrets@v1
68+ id : bot_secrets
69+ with :
70+ secret-ids : |
71+ BOT_TOKEN ,${{ secrets.BOT_TOKEN_SECRET_ARN }}
72+ parse-json-secrets : true
73+
74+ - name : Setup Git
75+ uses : actions/checkout@v2
76+ with :
77+ fetch-depth : 0
78+ token : ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
79+
80+ - name : Configure Git
81+ run : |
82+ git config user.name "github-actions"
83+ git config user.email "[email protected] " 84+
85+ - name : Extract Major.Minor Version and setup Env variable
86+ run : |
87+ echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
88+ echo "MAJOR_MINOR=$(echo ${{ github.event.inputs.version }} | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_ENV
89+
90+ - name : Determine release branch and checkout
91+ run : |
92+ RELEASE_BRANCH="release/v${MAJOR_MINOR}.x"
93+ git fetch origin $RELEASE_BRANCH
94+ git checkout -b "prepare-main-for-next-dev-cycle-${VERSION}" origin/$RELEASE_BRANCH
95+
96+ - name : Update version to next development version in main
97+ run : |
98+ DEV_VERSION="${{ github.event.inputs.version }}.dev0"
99+ sed -i "s/public final String VERSION = \".*\";/public final String VERSION = \"${DEV_VERSION}\";/" awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/ArtifactVersion.java
100+ VERSION="${{ github.event.inputs.version }}"
101+ git add awsagentprovider/src/main/java/software/amazon/opentelemetry/javaagent/providers/ArtifactVersion.java
102+
103+ - name : Append latest release checksum to release-build-metadata.json
104+ run : |
105+ ARTIFACT_NAME="aws-opentelemetry-agent.jar"
106+ curl -L -o $ARTIFACT_NAME https://github.com/aws-observability/aws-otel-java-instrumentation/releases/download/v${{ github.event.inputs.version }}/$ARTIFACT_NAME
107+
108+ CHECKSUM=$(shasum -a 256 $ARTIFACT_NAME | awk '{ print $1 }')
109+
110+ FILE="release-build-metadata.json"
111+ UPDATED_JSON=$(jq --arg version "${{ env.VERSION }}" \
112+ --arg name "$ARTIFACT_NAME" \
113+ --arg checksum "$CHECKSUM" \
114+ '.release += [{"version": $version, "checksum": [{"name": $name, "checksum": $checksum}]}]' "$FILE")
115+
116+ echo "$UPDATED_JSON" > "$FILE"
117+ git add release-build-metadata.json
118+
119+ - name : Push changes to Github
120+ run : |
121+ git commit -m "Prepare main for next development cycle: Update version to ${{ github.event.inputs.version }}"
122+ git push --set-upstream origin "prepare-main-for-next-dev-cycle-${{ github.event.inputs.version }}"
123+
124+ - name : Create Pull Request to main
125+ env :
126+ GITHUB_TOKEN : ${{ env.BOT_TOKEN_GITHUB_RW_PATOKEN }}
127+ run : |
128+ DEV_VERSION="${{ github.event.inputs.version }}.dev0"
129+ gh pr create --title "Post release $VERSION: Update version to $DEV_VERSION" \
130+ --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.
131+
132+ This PR should only be merge when release for version v$VERSION is success.
133+
134+ By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice." \
135+ --head prepare-main-for-next-dev-cycle-${VERSION} \
136+ --base main
0 commit comments