Prevents from failing GHA builds in PRs #54
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: K2hash Java CI | |
on: | |
# Trigger the workflow on push or pull request, | |
# but only for the main branch | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
# Trigger the workflow on release, | |
# but only when published | |
release: | |
types: | |
- published | |
jobs: | |
build: | |
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]') && ! contains(toJSON(github.event.commits.*.message), '[ci skip]')" | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: [ '8', '11', '17', '21' ] | |
name: Java ${{ matrix.java }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: ${{ matrix.java }} | |
- name: Set environments | |
run: | | |
echo "COMMON_MAVEN_OPTS=-Dmaven.compiler.failOnWarning=true -Dmaven.compiler.showDeprecation=true -Dmaven.compiler.verbose=true -Dmaven.compiler.debuglevel=lines,vars,source" >> "$GITHUB_ENV" | |
- name: Install dependent packages | |
run: | | |
sudo apt-get install -y curl | |
curl -s https://packagecloud.io/install/repositories/antpickax/stable/script.deb.sh | sudo bash | |
sudo apt-get install -y k2hash-dev | |
- name: Run checkstyle | |
run: | | |
mvn ${{ env.COMMON_MAVEN_OPTS }} checkstyle:check | |
- name: Run package on version 8 | |
if: "matrix.java == '8'" | |
run: | | |
mvn ${{ env.COMMON_MAVEN_OPTS }} -Dmaven.compiler.target=8 package | |
env: | |
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
- name: Run package on version other than 8 | |
if: "matrix.java != '8'" | |
run: | | |
mvn ${{ env.COMMON_MAVEN_OPTS }} -Dmaven.compiler.target=${{ matrix.java }} -Dmaven.compiler.source=${{ matrix.java }} -Dmaven.compiler.release=${{ matrix.java }} package | |
env: | |
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
- name: Run javadoc | |
run: | | |
mvn ${{ env.COMMON_MAVEN_OPTS }} javadoc:javadoc | |
- name: Deploy the docs to github | |
if: "github.event_name == 'release' && matrix.java == '21'" | |
run: | | |
mvn ${{ env.COMMON_MAVEN_OPTS }} site | |
env: | |
GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password | |
- name: Set up Apache Maven Central | |
uses: actions/setup-java@v4 | |
with: # running setup-java again overwrites the settings.xml | |
distribution: 'zulu' | |
java-version: ${{ matrix.java }} | |
server-id: central # Value of the distributionManagement/repository/id field of the pom.xml | |
server-username: MAVEN_USERNAME # env variable for username in deploy | |
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy | |
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase | |
- name: Publish to Apache Maven Central | |
if: "github.event_name == 'release' && matrix.java == '21'" | |
run: | | |
mvn ${{ env.COMMON_MAVEN_OPTS }} deploy -Prelease | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_CENTRAL_TOKEN: ${{ secrets.OSSRH_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |