Skip to content

Commit b152eb9

Browse files
committed
actions workflow updated
1 parent b9f37e2 commit b152eb9

File tree

1 file changed

+88
-4
lines changed

1 file changed

+88
-4
lines changed

.github/workflows/main.yml

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,99 @@ on:
33
push:
44
branches:
55
- main
6+
pull_request:
7+
branches:
8+
- main
9+
release:
10+
types:
11+
- released
612
jobs:
7-
jar:
13+
build:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
name: ${{ steps.build.outputs.name }}
17+
version: ${{ steps.build.outputs.version }}
18+
steps:
19+
- uses: actions/checkout@v2
20+
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
21+
- uses: actions/setup-java@v1
22+
with:
23+
java-version: '1.8'
24+
- name: build jar
25+
id: build
26+
run: |
27+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
28+
[ $GITHUB_EVENT_NAME == 'release' ] && VERSION=${{ github.event.release.tag_name }} && VERSION=${VERSION/v/}
29+
[ $GITHUB_EVENT_NAME == 'push' ] && VERSION+=-beta && VERSION+=.$(($(git tag -l "v$VERSION.*" | sort -nt. -k4 2>/dev/null | tail -1 | cut -d. -f4)+1))
30+
[ $GITHUB_EVENT_NAME == 'pull_request' ] && VERSION+=-dev.${{ github.event.pull_request.number }}
31+
mvn versions:set -DnewVersion=$VERSION
32+
mvn --batch-mode package
33+
NAME=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)-$VERSION
34+
echo ::set-output name=name::$NAME
35+
echo ::set-output name=version::$VERSION
36+
- uses: actions/upload-artifact@v2
37+
with:
38+
name: ${{ steps.build.outputs.name }}.jar
39+
path: target/${{ steps.build.outputs.name }}.jar
40+
beta:
41+
runs-on: ubuntu-latest
42+
if: (github.event_name != 'release')
43+
needs:
44+
- build
45+
steps:
46+
- uses: actions/download-artifact@v2
47+
with:
48+
name: ${{ needs.build.outputs.name }}.jar
49+
- name: Create Release
50+
id: create_release
51+
uses: actions/create-release@v1
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
with:
55+
tag_name: v${{ needs.build.outputs.version }}
56+
release_name: v${{ needs.build.outputs.version }}
57+
prerelease: ${{ github.event_name != 'release' }}
58+
- name: Upload Release Asset
59+
id: upload-release-asset
60+
uses: actions/upload-release-asset@v1
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
with:
64+
upload_url: ${{ steps.create_release.outputs.upload_url }}
65+
asset_path: ${{ needs.build.outputs.name }}.jar
66+
asset_name: ${{ needs.build.outputs.name }}.jar
67+
asset_content_type: application/zip
68+
deploy:
869
runs-on: ubuntu-latest
70+
if: (github.event_name == 'release')
71+
needs:
72+
- build
973
steps:
10-
- uses: actions/checkout@master
74+
- uses: actions/checkout@v2
75+
with:
76+
ref: main
1177
- uses: actions/setup-java@v1
1278
with:
1379
java-version: '1.8'
14-
- name: build and deploy jar
15-
run: mvn --batch-mode deploy
80+
- name: build jar
81+
id: build
82+
env:
83+
VERSION: ${{ needs.build.outputs.version }}
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
run: |
86+
mvn versions:set -DnewVersion=$VERSION
87+
mvn versions:commit
88+
mvn --batch-mode deploy
89+
- name: bump version
1690
env:
91+
VERSION: ${{ needs.build.outputs.version }}
1792
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
run: |
94+
VERSION=`echo $VERSION | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.`
95+
mvn versions:set -DnewVersion=$VERSION
96+
mvn versions:commit
97+
git config --global user.name 'ProjectBot'
98+
git config --global user.email '[email protected]'
99+
git add pom.xml
100+
git commit -m 'auto bump version with release'
101+

0 commit comments

Comments
 (0)