1+ #
2+ # Copyright 2025 Aiven Oy and project contributors
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing,
11+ # software distributed under the License is distributed on an
12+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
13+ # KIND, either express or implied. See the License for the
14+ # specific language governing permissions and limitations
15+ # under the License.
16+ #
17+ # SPDX-License-Identifier: Apache-2
18+
19+ # Workflow to check pull requests and new commits to main branches
20+ # This checks the source in the state as if after the merge.
21+ name : Main push checks
22+ on :
23+ push :
24+ branches :
25+ - ' main'
26+
27+ # Disallow concurrent runs for the same PR by cancelling in-progress runs
28+ # when new commits are pushed
29+ concurrency :
30+ group : ${{ github.workflow }}-${{ github.ref }}
31+ cancel-in-progress : true
32+
33+ jobs :
34+ # builds aiven-commons and all modules. Does not deploy.
35+ build :
36+
37+ strategy :
38+ matrix :
39+ java : [ 17, 20, 21, 25 ]
40+ fail-fast : false
41+
42+ name : JDK-${{ matrix.java }} Build
43+ runs-on : ubuntu-latest
44+ steps :
45+ - name : Checkout code
46+ uses : actions/checkout@v6
47+
48+ - name : Configure artifact caching
49+ uses : actions/cache@v5
50+ with :
51+ path : ~/.m2/repository
52+ key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
53+ restore-keys : |
54+ ${{ runner.os }}-maven-
55+
56+ - name : Set up JDK ${{ matrix.java }}
57+ uses : actions/setup-java@v4
58+ with :
59+ distribution : ' adopt'
60+ java-version : ${{ matrix.java }}
61+ cache : ' maven'
62+
63+ - name : Extract version info
64+ run : |
65+ echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT;
66+ echo "java_version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT;
67+ id : project
68+
69+ - name : Build ${{ steps.project.outputs.version }}
70+ run : mvn -e -B -V -ntp clean verify
71+
72+ - name : " Upload build failure reports"
73+ uses : actions/upload-artifact@v7
74+ if : failure()
75+ with :
76+ name : unit-test-results-${{ matrix.java }}-JDK
77+ path : |
78+ **/target/*-reports/**
79+ retention-days : 1
80+
81+ # javadoc has issues with java 17
82+ - name : Generate javadoc
83+ if : ${{ matrix.java != 17 }}
84+ run : mvn -e -B -V -ntp javadoc:javadoc
85+
86+ - name : Build site
87+ if : ${{ matrix.java != 17 }}
88+ run : mvn -e -B -V -ntp site site:stage
89+
90+
91+ # only run Publish if all builds completed
92+ publish :
93+ name : Publish
94+ needs : [build]
95+ runs-on : ubuntu-latest
96+ steps :
97+
98+ - name : Checkout code
99+ uses : actions/checkout@v6
100+
101+ - name : Extract version info
102+ run : |
103+ echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT;
104+ echo "java_version=$(mvn -q -Dexec.executable=echo -Dexec.args='${jdk.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT;
105+ id : project
106+
107+ - name : Set up JDK ${{ steps.project.outputs.java_version }}
108+ if : contains(steps.project.outputs.version , '-SNAPSHOT')
109+ uses : actions/setup-java@v4
110+ with :
111+ distribution : ' adopt'
112+ java-version : ${{ steps.project.outputs.java_version }}
113+ cache : ' maven'
114+
115+ - name : Setup Maven settings.xml
116+ if : contains(steps.project.outputs.version , '-SNAPSHOT')
117+ uses : s4u/maven-settings-action@v4.0.0
118+ with :
119+ sonatypeSnapshots : true
120+ servers : |
121+ [{
122+ "id": "central-snapshot",
123+ "username": "${{ secrets.SONATYPE_ID }}",
124+ "password": "${{ secrets.SONATYPE_PASSWORD }}"
125+ }]
126+
127+ - name : Publish ${{ steps.project.outputs.version }}
128+ if : contains(steps.project.outputs.version , '-SNAPSHOT')
129+ run : mvn -P sign -P publish-snapshot -e -B -V -ntp -Dgpg.signer=bc deploy
130+ env :
131+ MAVEN_GPG_KEY : ${{ secrets.GPG_KEY }}
132+ MAVEN_GPG_PASSPHRASE : ${{ secrets.GPG_PASSWORD }}
133+
134+ - name : ${{ steps.project.outputs.version }} Not Snapshot
135+ if : ${{ !contains(steps.project.outputs.version , '-SNAPSHOT') }}
136+ run : echo ${{ steps.project.outputs.version }} is not a snapshot -- not publishing"
137+
138+ # only run site if all builds completed
139+ site :
140+ name : Build Site
141+ needs : [ build ]
142+ runs-on : ubuntu-latest
143+ steps :
144+
145+ - name : Checkout code
146+ uses : actions/checkout@v6
147+
148+ - name : Set up JDK 20
149+ uses : actions/setup-java@v4
150+ with :
151+ distribution : ' adopt'
152+ java-version : 20
153+ cache : ' maven'
154+
155+ - name : Build site
156+ run : mvn -e -B -V -ntp site site:stage
157+
158+ - name : Upload artifact
159+ uses : actions/upload-pages-artifact@v3
160+ with :
161+ path : ./target/staging
162+
163+ # Deployment site
164+ deploy :
165+ name : Deploy site
166+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
167+ permissions :
168+ contents : read
169+ pages : write
170+ id-token : write
171+ environment :
172+ name : github-pages
173+ url : ${{ steps.deployment.outputs.page_url }}
174+ runs-on : ubuntu-latest
175+ needs : [site]
176+ steps :
177+ - name : Deploy to GitHub Pages
178+ id : deployment
179+ uses : actions/deploy-pages@v4
0 commit comments