-
Notifications
You must be signed in to change notification settings - Fork 5
108 lines (93 loc) · 3.54 KB
/
build.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle 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-gradle
name: Java CI with Gradle
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
concurrency:
group: ci-tests-${{ github.ref }}-1
cancel-in-progress: true
env:
# https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request
GITHUB_PR_NUMBER: ${{github.event.pull_request.number}}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# - name: debug
# run: echo "${{ toJSON(github.event)}}"
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'zulu'
- name: Setup Gradle
id: setup-gradle
uses: gradle/actions/setup-gradle@v4
- name: Build with Gradle
run: ./gradlew build --stacktrace
- name: Upload build reports
uses: actions/upload-artifact@v4
if: failure()
with:
name: build-reports
path: "**/build/reports/*"
- name: Upload Test Report
uses: actions/upload-artifact@v4
if: failure()
with:
name: junit-test-results
path: '**/build/test-results/test/TEST-*.xml'
retention-days: 1
- name: Comment with build scan url
uses: actions/github-script@v7
if: github.event_name == 'pull_request' && failure()
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '❌ ${{ github.workflow }} failed: ${{ steps.build.outputs.build-scan-url }}'
})
- name: Publish snapshot when on master
if: success() && github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }}
ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.ORG_GRADLE_PROJECT_OSSRHUSERNAME }}
ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.ORG_GRADLE_PROJECT_OSSRHPASSWORD }}
run: ./gradlew publish -Ppublish.central=true -Psemver.stage=snapshot
# This job will update the PR with the JUnit report
# In order to be able to make the most of it this job in particular has
# augmented permissions.
junit-report:
name: JUnit Report
if: |
failure()
&& github.event_name == 'pull_request'
needs: [ build ]
permissions:
checks: write # for mikepenz/action-junit-report
runs-on: ubuntu-latest
steps:
- name: Download Test Report
uses: actions/download-artifact@v4
with:
name: junit-test-results
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
with:
check_name: Test Report
commit: ${{github.event.workflow_run.head_sha}}
report_paths: '**/build/test-results/test/TEST-*.xml'