|
| 1 | +name: Nightly CI Build and Snapshot Release |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: '0 2 * * *' |
| 5 | + |
| 6 | +jobs: |
| 7 | + verify_commit: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + name: Verify latest commit |
| 10 | + outputs: |
| 11 | + RUN_BUILD: ${{ steps.verify_commit.outputs.RUN_BUILD }} |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v3 |
| 14 | + - id: verify_commit |
| 15 | + name: Verify latest commit is less than 24 hours |
| 16 | + if: ${{ github.event_name == 'schedule' }} |
| 17 | + run: echo '::set-output name=RUN_BUILD::'$(test -n "$(git log --format=%H --since='24 hours ago')" && echo 'true' || echo 'false') |
| 18 | + |
| 19 | + build-natives: |
| 20 | + name: Build native images |
| 21 | + runs-on: ${{ matrix.os }} |
| 22 | + needs: verify_commit |
| 23 | + if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'true' }} |
| 24 | + strategy: |
| 25 | + matrix: |
| 26 | + os: [windows-latest, ubuntu-latest, macos-latest] |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v3 |
| 30 | + with: |
| 31 | + submodules: recursive |
| 32 | + |
| 33 | + - uses: graalvm/setup-graalvm@v1 |
| 34 | + with: |
| 35 | + java-version: '17.0.7' |
| 36 | + distribution: 'graalvm' |
| 37 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + native-image-job-reports: 'true' |
| 39 | + |
| 40 | + - name: Build native images with nativ maven plugin and extract in tar.gz |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + mvn -B -ntp -Pnative -DskipTests=true package |
| 44 | +
|
| 45 | + - uses: actions/upload-artifact@v3 |
| 46 | + with: |
| 47 | + name: natives |
| 48 | + path: cli/target/*.tar.gz |
| 49 | + |
| 50 | + build: |
| 51 | + name: Build Project and Deploy |
| 52 | + needs: [build-natives, verify_commit] |
| 53 | + if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'true' }} |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - name: Checkout code |
| 57 | + uses: actions/checkout@v3 |
| 58 | + with: |
| 59 | + submodules: recursive |
| 60 | + - name: Set up JDK |
| 61 | + uses: actions/setup-java@v1 |
| 62 | + with: |
| 63 | + java-version: '17' |
| 64 | + - uses: actions/download-artifact@v3 |
| 65 | + - name: Make natives available and build project |
| 66 | + run: | |
| 67 | + mv ./natives/* ./cli/ |
| 68 | + mvn -B -ntp -Dstyle.color=always install |
| 69 | + - name: Deploy to OSSRH nexus |
| 70 | + env: |
| 71 | + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} |
| 72 | + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} |
| 73 | + run: mvn --settings .mvn/settings.xml -DskipTests=true -Darchetype.test.skip=true -Dmaven.install.skip=true -Dstyle.color=always -B -ntp deploy |
| 74 | + |
| 75 | + cancel: |
| 76 | + name: Cancel this workflow |
| 77 | + runs-on: ubuntu-latest |
| 78 | + needs: verify_commit |
| 79 | + if: ${{ needs.verify_commit.outputs.RUN_BUILD == 'false' }} |
| 80 | + env: |
| 81 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + OWNER: ${{ github.repository_owner }} |
| 83 | + REPO: ${{ github.event.repository.name }} |
| 84 | + RUN_ID: ${{ github.run_id }} |
| 85 | + steps: |
| 86 | + - run: | |
| 87 | + curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/$OWNER/$REPO/actions/runs/$RUN_ID/cancel" |
0 commit comments