-
Notifications
You must be signed in to change notification settings - Fork 4
106 lines (95 loc) · 3.65 KB
/
master-build.yml
File metadata and controls
106 lines (95 loc) · 3.65 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: 'master_build'
on:
push:
branches: [ master ]
env:
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
jobs:
build_job:
runs-on: ubuntu-latest
name: Build & Test Microservice
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK 21
uses: actions/setup-java@v1
with:
java-version: 21
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Check version
if: github.event_name != 'pull_request'
id: version-check
run: |
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Project version: $VERSION"
if [[ "$VERSION" =~ -SNAPSHOT$ ]]; then
echo "⚠️ Version is snapshot: $VERSION - skipping publish"
echo "should_publish=false" >> $GITHUB_OUTPUT
VERSION=latest
else
echo "✅ Version is not a snapshot: $VERSION - will publish"
echo "should_publish=true" >> $GITHUB_OUTPUT
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- uses: s4u/maven-settings-action@v4.0.0
with:
servers: |
[{
"id": "central",
"username": "${{ secrets.OSSRH_USERNAME }}",
"password": "${{ secrets.OSSRH_PASSWORD }}"
},
{
"id": "central-portal-snapshots",
"username": "${{ secrets.OSSRH_USERNAME }}",
"password": "${{ secrets.OSSRH_PASSWORD }}"
}]
- name: Import GPG key
if: steps.version-check.outputs.should_publish == 'true'
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Build
if: steps.version-check.outputs.should_publish == 'false'
run: >
./mvnw verify
-Dci.buildNumber=$GITHUB_RUN_NUMBER
-U -B $MAVEN_OPTS
- name: Build & Deploy
if: steps.version-check.outputs.should_publish == 'true'
run: >
./mvnw deploy
-Dci.buildNumber=$GITHUB_RUN_NUMBER
-U -B -Prelease,release-central,gpg $MAVEN_OPTS
- name: Build Image
run: ./scripts/docker_build ${{ steps.version-check.outputs.version }}
- name: Upload Image
run: ./scripts/docker_push ${{ steps.version-check.outputs.version }}
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Install tools
if: steps.version-check.outputs.should_publish == 'true'
run: |
git config --global user.email "ci@example.com"
git config --global user.name "CI Server"
- name: Site
if: steps.version-check.outputs.should_publish == 'true'
run: >
./mvnw post-integration-test site scm-publish:publish-scm
-DsurefireArgs=-Dspring.profiles.active=TEST
-Dargs=-Dspring.profiles.active=TEST
-Dscmpublish.pubScmUrl=scm:git:https://openwms:$PUSHKEY@github.com/spring-labs/org.openwms.services.git
-DdeveloperConnectionUrl=scm:git:https://openwms:$PUSHKEY@github.com/spring-labs/org.openwms.services.git
-Dci.buildNumber=$GITHUB_RUN_NUMBER
-Prelease,coverage -B $MAVEN_OPTS
env:
PUSHKEY: ${{ secrets.GITHUB_TOKEN }}