-
Notifications
You must be signed in to change notification settings - Fork 85
54 lines (50 loc) · 1.89 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
name: Build Test Deploy master
on:
push:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 9 ]
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven, Deploy snapshot to maven central
run: |
export MY_POM_VERSION=`mvn -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
if [[ $MY_POM_VERSION =~ ^.*SNAPSHOT$ ]];
then
mvn --no-transfer-progress -B verify --file pom.xml
export MY_JAVA_VERSION=`java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1`
echo "JAVA VERSION" ${MY_JAVA_VERSION}
if [[ ${MY_JAVA_VERSION} == "8" ]];
then
export MY_POM_VERSION=`mvn -q -Dexec.executable="echo" -Dexec.args='${projects.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.3.1:exec`
echo "POM VERSION" ${MY_POM_VERSION}
mvn --no-transfer-progress -B clean deploy
else
echo "not deploying on java version: " ${MY_JAVA_VERSION}
fi
else
echo "not building and maven publishing project as it is a release version: " ${MY_JAVA_VERSION}
fi
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}