Skip to content

Update pre-release.yml #16

Update pre-release.yml

Update pre-release.yml #16

Workflow file for this run

#
# Copyright 2025 Aiven Oy and project contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2
# Workflow to check pull requests and new commits to main branches
# This checks the source in the state as if after the merge.
name: Main push checks
on:
push:
branches:
- 'main'
permissions:
contents: read
# Disallow concurrent runs for the same PR by cancelling in-progress runs
# when new commits are pushed
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# builds aiven-commons and all modules. Does not deploy.
build:
strategy:
matrix:
java: [ 17, 20, 21, 25 ]
fail-fast: false
name: JDK-${{ matrix.java }} Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Configure artifact caching
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v5
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Extract version info
run: |
echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT;
echo "java_version=$(mvn -q -Dexec.executable=echo -Dexec.args='${jdk.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT;
id: project
- name: Build ${{ steps.project.outputs.version }}
run: mvn -e -B -V -ntp clean verify
- name: "Upload build failure reports"
uses: actions/upload-artifact@v7
if: failure()
with:
name: unit-test-results-${{ matrix.java }}-JDK
path: |
**/target/*-reports/**
retention-days: 1
# javadoc has issues with java 17
- name: Generate javadoc
if: ${{ matrix.java != 17 }}
run: mvn -e -B -V -ntp javadoc:javadoc
- name: Build site
if: ${{ matrix.java != 17 }}
run: mvn -e -B -V -ntp site
# only run Publish if all builds completed
publish:
name: Publish
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Extract version info
run: |
echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT;
echo "java_version=$(mvn -q -Dexec.executable=echo -Dexec.args='${jdk.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT;
id: project
- name: Set up JDK ${{ steps.project.outputs.java_version }}
if: contains(steps.project.outputs.version , '-SNAPSHOT')
uses: actions/setup-java@v5
with:
distribution: 'adopt'
java-version: ${{ steps.project.outputs.java_version }}
cache: 'maven'
- name: Setup Maven settings.xml
if: contains(steps.project.outputs.version , '-SNAPSHOT')
uses: s4u/maven-settings-action@v4.0.0
with:
sonatypeSnapshots: true
servers: |
[{
"id": "central-snapshot",
"username": "${{ secrets.SONATYPE_ID }}",
"password": "${{ secrets.SONATYPE_PASSWORD }}"
}]
- name: Publish ${{ steps.project.outputs.version }}
if: contains(steps.project.outputs.version , '-SNAPSHOT')
run: mvn -P sign -P publish-snapshot -e -B -V -ntp -Dgpg.signer=bc deploy
env:
MAVEN_GPG_KEY: ${{ secrets.GPG_KEY }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSWORD }}
- name: ${{ steps.project.outputs.version }} Not Snapshot
if: ${{ !contains(steps.project.outputs.version , '-SNAPSHOT') }}
run: echo ${{ steps.project.outputs.version }} is not a snapshot -- not publishing"
# only run site if all builds completed
site:
name: Build Site
needs: [ build ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up JDK 20
uses: actions/setup-java@v5
with:
distribution: 'adopt'
java-version: 20
cache: 'maven'
- name: Build site
run: mvn -e -B -V -ntp site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./target/site
# Deployment site
deploy:
name: Deploy site
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: [site]
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4