76 lines (63 loc) · 2.38 KB
/
cd.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
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CD with Maven
on:
push:
branches: [ develop, master ]
pull_request:
branches: [ develop, master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Set up Maven
env:
GPG_KEY: ${{ secrets.MAVEN_KEY }}
run: |
export GPG_TTY=$(tty)
cp .mvn.settings.xml $HOME/.m2/settings.xml
echo "$GPG_KEY" >> codesigning.asc
gpg --batch --import codesigning.asc
shred --remove codesigning.asc
- name: Set up Terraform
run: |
curl -g https://releases.hashicorp.com/terraform/0.12.9/terraform_0.12.9_linux_amd64.zip -o /tmp/terraform.zip
sudo unzip /tmp/terraform.zip -d /usr/bin
- name: Build with Maven
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
cd tf-build-tools
./mvnw clean test coveralls:report -DrepoToken="$COVERALLS_REPO_TOKEN"
cd ..
- name: Deploy
id: deploy
env:
OSSRH_USERNAME: ${{ secrets.SONATYPE_USER }}
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PW }}
GPG_KEY_PW: ${{ secrets.MAVEN_KEY_PW }}
GPG_KEY_ID: ${{ secrets.MAVEN_KEY_ID }}
run: |
cd tf-build-tools
VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
PROFILE=""
if [ "$BRANCH_NAME" == "develop" ] && ![ echo $VERSION | grep -q SNAPSHOT ]; then
DOTS=$VERSION | sed -e 's/\(.\)/\n/g' | grep l | wc -l
# Ensure that the build number is in the 4th [semver] position
if [ "$DOTS" < "3" ]; then
VERSION="${VERSION}.0"
fi
VERSION="${VERSION}-${GITHUB_RUN_NUMBER}"
echo "***** VERSION is $VERSION ******"
./mvnw versions:set -DnewVersion="${VERSION}"
else
PROFILE="release"
fi
# Stage for Maven Central Deployment
export GPG_TTY=$(tty)
./mvnw deploy -DskipTests=true -P ${PROFILE}