-
Notifications
You must be signed in to change notification settings - Fork 7
129 lines (108 loc) · 5.15 KB
/
post-release-version-bump.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Post Release - Prepare Main for Next Development Cycle
on:
workflow_dispatch:
inputs:
version:
description: 'Version number (e.g., 1.0.1)'
required: true
default: '0.1.0'
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=$(jq -r '.version' aws-distro-opentelemetry-node-autoinstrumentation/package.json)
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 main
git checkout -b "prepare-main-for-next-dev-cycle-${VERSION}" origin/main
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Update version to next development version in main
run: |
DEV_VERSION="${{ github.event.inputs.version }}.dev0"
sed -i'' -e "s/\"version\": \".*\"/\"version\": \"${DEV_VERSION}\"/" aws-distro-opentelemetry-node-autoinstrumentation/package.json
sed -i'' -e "s/\"version\": \".*\"/\"version\": \"${DEV_VERSION}\"/" docker-utils/package.json
sed -i'' -e "s/\"version\": \".*\"/\"version\": \"${DEV_VERSION}\"/" package.json
VERSION="${{ github.event.inputs.version }}"
npm install
sed -i "s|\(/aws-observability/adot-autoinstrumentation-node:\)v[0-9]\+\.[0-9]\+\.[0-9]\+|\1v${{github.event.inputs.version}}|g" .github/workflows/daily-scan.yml
git add .
git status
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