1
- name : Version handling
2
-
1
+ name : Release Process
3
2
on :
3
+ push :
4
+ branches : ['release/**', 'release-*']
4
5
pull_request :
5
- types :
6
- - closed
7
- branches :
8
- - master
6
+ types : [closed]
7
+ branches : [master]
9
8
10
9
jobs :
11
- version-update :
12
- # This version does not run on self-opened PRs
13
- if : ${{ github.event.pull_request.merged == true && github.event.pull_request.user.login != 'github-actions[bot]' }}
14
- runs-on : ubuntu-latest
15
- steps :
16
- - name : Checkout source code
17
- uses : actions/checkout@v4
18
- with :
19
- fetch-depth : 0
20
- # Sets up Java version
21
- - name : Set up Java
22
- uses : actions/setup-java@v4
23
- with :
24
- distribution : ' adopt'
25
- java-package : jdk
26
- java-version : ' 8'
27
- # Semantic versioning
28
- - name : Semantic versioning
29
- id : versioning
30
-
31
- with :
32
- tag_prefix : " "
33
- # A string which, if present in a git commit, indicates that a change represents a
34
- # major (breaking) change, supports regular expressions wrapped with '/'
35
- major_pattern : " (MAJOR)"
36
- # Same as above except indicating a minor change, supports regular expressions wrapped with '/'
37
- minor_pattern : " (MINOR)"
38
- # A string to determine the format of the version output
39
- version_format : " ${major}.${minor}.${patch}"
40
- # Check, whether there is an existing branch "version_<version>" or an open PR "version_<version>" -> "master"
41
- # and store the results as environment variables
42
- - name : Check if branch and PR exist
43
- # The second command was copied from https://stackoverflow.com/questions/73812503/github-action-stop-the-action-if-pr-already-exists
44
- run : |
45
- echo VERSION_BRANCH_EXISTS=$(git ls-remote --heads origin refs/heads/version_${{ steps.versioning.outputs.version }} | wc -l) >> $GITHUB_ENV
46
- echo PR_EXISTS=$(gh pr list \
47
- --repo "$GITHUB_REPOSITORY" \
48
- --json baseRefName,headRefName \
49
- --jq '
50
- map(select(.baseRefName == "master" and .headRefName == "version_${{ steps.versioning.outputs.version }}"))
51
- | length
52
- ') >> $GITHUB_ENV
53
- env :
54
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
55
- # If the branch "version_<version>" does not exist, create the branch and update the version in all files
56
- - name : Create branch and update PathExpression version
57
- if : ${{ env.VERSION_BRANCH_EXISTS == '0' }}
58
- run : |
59
- git config --global user.email "github-actions[bot]@users.noreply.github.com"
60
- git config --global user.name "github-actions[bot]"
61
- git checkout -b version_${{ steps.versioning.outputs.version }}
62
- mvn build-helper:parse-version versions:set -DnewVersion=\${{ steps.versioning.outputs.version }} versions:commit
63
- git ls-files | grep 'pom.xml$' | xargs git add
64
- git commit --allow-empty -am "Update PathExpression version to ${{ steps.versioning.outputs.version }}"
65
- git push origin version_${{ steps.versioning.outputs.version }}
66
- # If a PR "version_<version>" -> "master" does not exist, create the PR
67
- - name : Open pull request for version update
68
- if : ${{ env.PR_EXISTS == '0' }}
69
- run : |
70
- gh pr create -B master -H version_${{ steps.versioning.outputs.version }} -t "Update PathExpression version to ${{ steps.versioning.outputs.version }}" -b "This PR was created by the version-update workflow. Please make sure to delete the branch after merging, otherwise future workflows might fail."
71
- env :
72
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
73
-
74
- version-release :
75
- # This job runs only on merged PRs, which were opened by the version-update job
76
- if : ${{ github.event.pull_request.merged == true && github.event.pull_request.user.login == 'github-actions[bot]' }}
10
+ handle-version :
77
11
runs-on : ubuntu-latest
12
+ permissions :
13
+ contents : write
14
+ pull-requests : write
78
15
steps :
79
- - name : Checkout source code
80
- uses : actions/checkout@v4
81
- with :
82
- fetch-depth : 0
83
- # Semantic versioning
84
- - name : Semantic versioning
85
- id : versioning
86
-
16
+ - uses : secure-software-engineering/actions/version@develop
87
17
with :
88
- tag_prefix : " "
89
- # A string which, if present in a git commit, indicates that a change represents a
90
- # major (breaking) change, supports regular expressions wrapped with '/'
91
- major_pattern : " (MAJOR)"
92
- # Same as above except indicating a minor change, supports regular expressions wrapped with '/'
93
- minor_pattern : " (MINOR)"
94
- # A string to determine the format of the version output
95
- version_format : " ${major}.${minor}.${patch}"
96
- # Create a tag with the newest version to prepare a release
97
- - name : Create tag for new version
98
- run : |
99
- git config --global user.email "${{ github.actor }}@users.noreply.github.com"
100
- git config --global user.name "${{ github.actor }}"
101
- git tag -a ${{ steps.versioning.outputs.version }} -m "PathExpression version ${{ steps.versioning.outputs.version }}"
102
- git push origin ${{ steps.versioning.outputs.version }}
18
+ token : ${{ secrets.GITHUB_TOKEN }}
19
+ java_version : ' 11'
20
+ java_distribution : ' temurin'
21
+ target_branch : ' master'
0 commit comments