-
Notifications
You must be signed in to change notification settings - Fork 22
52 lines (44 loc) · 1.56 KB
/
build.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
name: Build and Version Update
on:
push:
branches:
- main
- merge
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '17' # or your preferred Java version
distribution: 'adopt'
- name: Generate build number
id: buildnumber
uses: einaregilsson/build-number@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update version in pom.xml and plugin.yml
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
IFS='.' read -ra VERSION_PARTS <<< "$VERSION"
PATCH=$((VERSION_PARTS[2] + 1))
NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$PATCH-dev-b${{ steps.buildnumber.outputs.build_number }}"
mvn versions:set -DnewVersion=$NEW_VERSION
sed -i "s/^version: .*$/version: $NEW_VERSION/" src/main/resources/plugin.yml
- name: Build with Maven
run: mvn clean package
- name: Commit and push if changed
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add pom.xml src/main/resources/plugin.yml
git commit -m "Update version to ${{ steps.buildnumber.outputs.build_number }}" || exit 0
git push
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Plugin-JAR
path: target/*.jar