Enable branch-specific versions in internal maven repo #122
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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-amazoncorretto-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: | |
matrix: | |
java-version: [11, 17] | |
include: | |
- java-version: 11 | |
mvn-goal: deploy | |
- java-version: 17 | |
mvn-goal: install | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK ${{ matrix.java-version }} | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.java-version }} | |
distribution: 'adopt' | |
cache: maven | |
- 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: Check env | |
run: echo ${GITHUB_REF_NAME//\//-} | |
- name: Build with Maven | |
run: mvn -B clean ${{ matrix.mvn-goal }} -Drepo.snapshots.url=${{ secrets.SNAPSHOTS_URL }} | |
- name: Run Demo App | |
run: | | |
ls -la NetLicensingClient-demo/target/ | |
java -jar NetLicensingClient-demo/target/netlicensing-client-demo.jar -r CallEveryAPIMethod |