-
-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (122 loc) · 4.46 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Continuous Integration
name: Build
on:
push:
branches:
- '*'
pull_request:
branches:
- main
- develop
jobs:
build:
name: Build on JDK${{ matrix.jdk }}
runs-on: ubuntu-latest
strategy:
matrix:
jdk: [ 11, 17, 21, 23 ]
env:
is_latest_jdk: ${{ matrix.jdk == 23 && 'yes' || '' }}
is_main: ${{ github.ref_name == github.event.repository.default_branch && 'yes' || '' }}
is_develop: ${{ github.ref_name == 'develop' && 'yes' || '' }}
is_fork: ${{ github.event_name == 'pull_request' && 'yes' || '' }}
steps:
# ================================
# SHALLOW CLONE
# ================================
- name: Shallow clone
if: ${{ !env.is_latest_jdk || env.is_fork }}
uses: actions/checkout@v4
# ================================
# CHECKOUT
# ================================
- name: Checkout git branch
if: ${{ env.is_latest_jdk && !env.is_fork }}
uses: actions/checkout@v4
with:
# Fetch all history for all tags and branches (recommended by SonarQube)
fetch-depth: 0
# ================================
# VALIDATE GRADLE WRAPPER
# ================================
- name: Validate Gradle Wrapper files
if: ${{ env.is_latest_jdk }}
uses: gradle/actions/wrapper-validation@v4
# ================================
# SET UP JDK
# ================================
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-package: jdk
java-version: ${{ matrix.jdk }}
# ================================
# SET UP GRADLE
# ================================
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"
cache-read-only: ${{ !env.is_main && !env.is_develop }}
# ================================
# EXPORT GRADLE PROPERTIES
# ================================
- name: Export Gradle properties
id: properties
uses: guillermocalvo/gradle-properties@v3
with:
output_file: ${{ github.output }}
export: version,previousVersion
# ================================
# BUILD
# ================================
- name: Build version ${{ steps.properties.outputs.version }}
run: ./gradlew build -x check
# ================================
# CHECK
# ================================
- name: Check
run: ./gradlew check
# ================================
# COMPATIBILITY REPORT
# ================================
- name: Compatibility with version ${{ steps.properties.outputs.previousVersion }}
if: ${{ env.is_latest_jdk }}
# $GITHUB_STEP_SUMMARY supports content up to a size of 1024k
run: head -c 1MiB ./api-compatibility/build/report.md >> $GITHUB_STEP_SUMMARY
# ================================
# CACHE SONARCLOUD PACKAGES
# ================================
- name: Cache SonarCloud packages
if: ${{ env.is_latest_jdk && !env.is_fork }}
uses: actions/cache@v4
with:
key: ${{ runner.os }}-sonar
path: |
~/.sonar/cache
restore-keys: |
${{ runner.os }}-sonar
# ================================
# ANALYZE WITH SONARCLOUD
# ================================
- name: Analyze with SonarCloud
if: ${{ env.is_latest_jdk && !env.is_fork }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io
SONAR_ORGANIZATION: leakyabstractions
run: ./gradlew sonar
# ================================
# PUBLISH SNAPSHOT
# ================================
- name: Publish snapshot version ${{ steps.properties.outputs.version }}
if: ${{ env.is_latest_jdk && !env.is_fork && env.is_main && endsWith(steps.properties.outputs.version, '-SNAPSHOT') }}
env:
ORG_GRADLE_PROJECT_githubUsername: ${{ secrets.PUBLISH_USERNAME }}
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.PUBLISH_PASSWORD }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
run: ./gradlew publish -Psnapshot