-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (63 loc) · 2.17 KB
/
maven.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
63
64
65
66
67
68
69
70
71
72
73
74
name: Java CI with Maven
on:
push:
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Get version
id: get_version
run: echo ::set-output name=VERSION::$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.6.0:exec)
- name: Build & Push docker image
id: build_docker
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{github.repository}}
push: true
tag_with_ref: true
add_git_labels: true
- name: Verify version
id: verify_version
if: github.ref == 'refs/heads/master'
run: |
if [[ "${{ steps.get_version.outputs.VERSION }}" == *"-SNAPSHOT"* ]]; then
echo "Snapshot version are forbidden on master branch"
exit 1
fi
- name: Create Release
id: create_release
if: github.ref == 'refs/heads/master'
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.VERSION }}
release_name: Release ${{ steps.get_version.outputs.VERSION }}
body: |
Release ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
- name: Push docker image release
id: push_docker_release
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{github.repository}}
push: true
tags: ${{ steps.get_version.outputs.VERSION }}
add_git_labels: true