-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (59 loc) · 2.27 KB
/
build-deploy.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
name: Build-Deploy
on:
push:
branches:
- master
pull_request:
types: [closed]
jobs:
build-and-deploy-artifact:
name: Build and deploy to github package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Set up JDK 1.11
uses: actions/[email protected]
with:
java-version: 1.11
- name: Resolve/Update Dependencies
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.READER_TOKEN }}
run: mvn --settings .m2/maven-settings.xml package dependency:resolve-plugins dependency:go-offline
- name: Cache Maven dependencies
uses: actions/cache@preview
id: cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build (and run tests)
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.READER_TOKEN }}
if: steps.cache.outputs.cache-hit != 'true'
run: mvn --settings .m2/maven-settings.xml clean install
- name: Save test results
run: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \;
- name: Setting version
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# if: github.base_ref == 'master'
run: |
export GIT_COMMIT_HASH=$(git log -n 1 --pretty=format:'%h')
export GIT_COMMIT_DATE=$(git log -1 --pretty='%ad' --date=format:'%Y%m%d%H%M%S')
export VERSION=1.${GIT_COMMIT_DATE}_${GIT_COMMIT_HASH}
echo "Setting version $VERSION"
mvn --settings .m2/maven-settings.xml versions:set -DnewVersion="$VERSION"
mvn --settings .m2/maven-settings.xml versions:commit
- name: Deploy to Github Package
# if: github.base_ref == 'master'
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn --settings .m2/maven-settings.xml source:jar-no-fork deploy -DskipTests=true -Dmaven.wagon.http.pool=false