Merge NJ3 modifications and code cleanup #59
This file contains hidden or 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
| name: Maven CI/CD | |
| on: [ push, pull_request ] | |
| jobs: | |
| test: | |
| runs-on : ubuntu-latest | |
| steps : | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Checkout NJ-image-test | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: GReD-Clermont/NucleusJ-tests-images | |
| ref: 'v1' | |
| path: test-images | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '11' | |
| distribution: 'adopt' | |
| server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | |
| settings-path: ${{ github.workspace }} # location for the settings.xml file | |
| - name: Cache Maven packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }} | |
| - name: Append branch name to version if 'push' did not happen on 'main' or a tag | |
| if: ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')}} | |
| run: | | |
| mvn versions:set -DremoveSnapshot | |
| mvn help:evaluate -N -Dexpression=project.version|grep -v '\[' | |
| VERSION=$(mvn help:evaluate -N -Dexpression=project.version|grep -v '\[') | |
| mvn versions:set -DnewVersion=$VERSION-${GITHUB_REF##*/} | |
| - name : Package and test | |
| run: mvn clean package | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: target | |
| deploy: | |
| if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) }} | |
| needs: [ test ] | |
| runs-on : ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '11' | |
| distribution: 'adopt' | |
| server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | |
| settings-path: ${{ github.workspace }} # location for the settings.xml file | |
| - name: Cache Maven packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2 | |
| key: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: ${{ runner.os }}-m2-${{ secrets.CACHE_VERSION }} | |
| - name: Append 'SNAPSHOT' to version if 'push' happened on 'main' | |
| if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| run: | | |
| mvn versions:set -DremoveSnapshot | |
| mvn help:evaluate -N -Dexpression=project.version|grep -v '\[' | |
| VERSION=$(mvn help:evaluate -N -Dexpression=project.version|grep -v '\[') | |
| mvn versions:set -DnewVersion=$VERSION-SNAPSHOT | |
| - name: Deploy | |
| run: mvn deploy -DskipTests -s $GITHUB_WORKSPACE/settings.xml | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} |