forked from microsoft/ApplicationInsights-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreusable-create-version-bump-pull-request.yml
More file actions
56 lines (48 loc) · 1.69 KB
/
reusable-create-version-bump-pull-request.yml
File metadata and controls
56 lines (48 loc) · 1.69 KB
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
name: Reusable - Create version bump pull request
on:
workflow_call:
inputs:
version:
type: string
required: true
# to help with partial release build failures
workflow_dispatch:
inputs:
version:
description: "Version"
required: true
jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set environment variables
env:
VERSION: ${{ inputs.version }}
run: |
if [[ $VERSION =~ ^([0-9]+\.[0-9]+)\.([0-9]+)$ ]]; then
major_minor="${BASH_REMATCH[1]}"
patch="${BASH_REMATCH[2]}"
else
echo "unexpected version: $VERSION"
exit 1
fi
echo "NEXT_VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV
- name: Update version
run: .github/scripts/update-version.sh $NEXT_VERSION
- name: Create pull request against main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
message="Update version to $NEXT_VERSION"
body="Update version to \`$NEXT_VERSION\`.
Since this PR was created using the default \`GITHUB_TOKEN\`, it will need to be closed and re-opened in order to trigger the normal pull request workflows.
"
branch="automation/update-version-to-${NEXT_VERSION}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$branch"
git commit -a -m "$message"
git push --set-upstream origin HEAD:$branch
gh pr create --title "$message" \
--body "$body"