-
Notifications
You must be signed in to change notification settings - Fork 7
81 lines (72 loc) · 2.96 KB
/
netlicesning-client-ci.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
75
76
77
78
79
80
81
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: NetLicensing Client - CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
build:
runs-on: [self-hosted]
container: maven:3-eclipse-temurin-17
env:
# This is needed, as java doesn't respect the environment variable $HOME, but gets the
# user home by other means from the system. The default user in the above container is
# 'root' with the home at '/root', while GitHub runner overrides $HOME to the mounted
# '/github/home'. As a result, maven uses the ~/.m2 at a different location than assumed
# by the standard GitHub actions like 'actions/setup-java', causing caching of the maven
# local repository not working.
# TODO(2K): This can be better solved by preparing a custom image for the container.
MAVEN_OPTS: -Duser.home=/github/home
strategy:
fail-fast: false
matrix:
java-version: [11, 17]
include:
- java-version: 11
jdk-suffix: ""
- java-version: 17
jdk-suffix: -jdk17
steps:
- uses: actions/checkout@v4
- name: Prepare maven settings.xml
run: |
mkdir -p ~/.m2
cat << EOF >~/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>nlic-snapshots</id>
<username>${{ secrets.SNAPSHOTS_USER }}</username>
<password>${{ secrets.SNAPSHOTS_PASS }}</password>
</server>
</servers>
</settings>
EOF
- name: Calculate branch suffix
# Ensure bash is used, as the script uses bash-specific syntax
shell: bash
run: |
if [ "$GITHUB_REF_NAME" = "master" ]
then
# No suffix when running against "master" branch
BRANCH_SUFFIX=${{ matrix.jdk-suffix }}
else
# When running from pull request, use "-pr-<N>" suffix, where <N> is a PR number
BRANCH_SUFFIX=${{ matrix.jdk-suffix }}-pr-${GITHUB_REF_NAME//\/merge/}
fi
echo "Branch suffix: '$BRANCH_SUFFIX'"
echo "BRANCH_SUFFIX=$BRANCH_SUFFIX" >> "$GITHUB_ENV"
- name: Build with Maven
run: |
mvn -B clean deploy \
-Drepo.snapshots.url=${{ secrets.SNAPSHOTS_URL }} \
-Dsha1=$BRANCH_SUFFIX \
-Djava.version=${{ matrix.java-version }}
- name: Run Demo App
run: |
ls -la NetLicensingClient-demo/target/
java -jar NetLicensingClient-demo/target/netlicensing-client-demo.jar -r CallEveryAPIMethod