-
Notifications
You must be signed in to change notification settings - Fork 26
62 lines (54 loc) · 1.92 KB
/
version_bump_pr.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
name: Version Bump PR
on:
workflow_dispatch:
inputs:
bump_type:
description: 'Version Bump Type (major, minor, patch)'
required: true
default: 'minor'
permissions:
contents: write
jobs:
version_bump_pr:
runs-on: ubuntu-latest
steps:
- uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: Check out the repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- name: Bump version
id: bump_version
run: |
BUMP_TYPE="${{ github.event.inputs.bump_type }}"
case "$BUMP_TYPE" in
major)
NEW_VERSION=$(cat VERSION | awk -F. '{printf "%d.0.0", $1+1}')
;;
minor)
NEW_VERSION=$(cat VERSION | awk -F. '{printf "%s.%d.0", $1, $2+1}')
;;
patch)
NEW_VERSION=$(cat VERSION | awk -F. '{printf "%s.%s.%d", $1, $2, $3+1}')
;;
*)
echo "Error: Invalid bump type"
exit 1
;;
esac
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo $NEW_VERSION > VERSION
sed -i "s/VERSION_STRING: Final = \"[0-9]*\.[0-9]*\.[0-9]*\"/VERSION_STRING: Final = \"$NEW_VERSION\"/" panther_analysis_tool/constants.py
- name: Create Branch and Pull Request
run: |
NEW_VERSION="${{ steps.bump_version.outputs.new_version }}"
git config user.name "dac-bot[bot]"
git config user.email "[email protected]"
git checkout -b "$NEW_VERSION"
git commit -a -m "Bump version to $NEW_VERSION"
git push --set-upstream origin "$NEW_VERSION"
gh pr create -t "Version bump to v$NEW_VERSION" -b "Bumping Version to v$NEW_VERSION ahead of release."
env:
GH_TOKEN: ${{ secrets.PANTHER_BOT_AUTOMATION_TOKEN }}