|
| 1 | +name: Java8+ with Maven |
| 2 | + |
| 3 | +on: [ push, pull_request ] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build-and-test-job: |
| 7 | + strategy: |
| 8 | + fail-fast: false |
| 9 | + matrix: |
| 10 | + java: [ 8, 11 ] |
| 11 | + os: [ ubuntu-latest, macOS-latest, windows-latest ] |
| 12 | + experimental: [ false ] |
| 13 | + include: |
| 14 | + - java: '>11' |
| 15 | + os: ubuntu-latest |
| 16 | + experimental: true |
| 17 | + |
| 18 | + name: JDK${{ matrix.java }} on ${{ matrix.os }} |
| 19 | + runs-on: ${{ matrix.os }} |
| 20 | + continue-on-error: ${{ matrix.experimental }} |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout source code |
| 24 | + uses: actions/checkout@v2 |
| 25 | + with: |
| 26 | + submodules: true |
| 27 | + |
| 28 | + - name: Setup Java |
| 29 | + uses: actions/setup-java@v1 |
| 30 | + with: |
| 31 | + java-version: ${{ matrix.java }} |
| 32 | + |
| 33 | + - name: Setup Maven cache |
| 34 | + uses: actions/cache@v1 |
| 35 | + with: |
| 36 | + path: ~/.m2 |
| 37 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 38 | + restore-keys: ${{ runner.os }}-m2 |
| 39 | + |
| 40 | + - name: Build and (headless) test with Maven |
| 41 | + uses: GabrielBB/xvfb-action@v1 |
| 42 | + with: |
| 43 | + run: mvn -B package --file pom.xml |
| 44 | + |
| 45 | + release-job: |
| 46 | + needs: build-and-test-job |
| 47 | + if: startsWith(github.repository, 'nbbrd/') && startsWith(github.ref, 'refs/tags/v') |
| 48 | + strategy: |
| 49 | + matrix: |
| 50 | + java: [ 11 ] |
| 51 | + os: [ ubuntu-latest ] |
| 52 | + |
| 53 | + name: Release on tag |
| 54 | + runs-on: ${{ matrix.os }} |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Checkout source code |
| 58 | + uses: actions/checkout@v2 |
| 59 | + with: |
| 60 | + submodules: true |
| 61 | + |
| 62 | + - name: Setup Java |
| 63 | + uses: actions/setup-java@v1 |
| 64 | + with: |
| 65 | + java-version: ${{ matrix.java }} |
| 66 | + |
| 67 | + - name: Setup Maven cache |
| 68 | + uses: actions/cache@v1 |
| 69 | + with: |
| 70 | + path: ~/.m2 |
| 71 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 72 | + restore-keys: ${{ runner.os }}-m2 |
| 73 | + |
| 74 | + - name: Build with Maven |
| 75 | + run: mvn -B package --file pom.xml -DskipTests=true |
| 76 | + |
| 77 | + - name: Create dummy file if no assets |
| 78 | + run: test -d "binaries" || (mkdir binaries && echo "no assets" > binaries/no_assets.txt) |
| 79 | + |
| 80 | + - name: Create draft release and upload assets |
| 81 | + uses: xresloader/upload-to-github-release@v1 |
| 82 | + env: |
| 83 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + with: |
| 85 | + file: 'binaries/*' |
| 86 | + |
| 87 | + - name: Deploy with Maven |
| 88 | + run: test -f ci.settings.xml && mvn -B deploy -Dmaven.test.skip -s ci.settings.xml -P deploy-releases |
| 89 | + env: |
| 90 | + CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} |
| 91 | + CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} |
0 commit comments