Skip to content

Dependency updates

Dependency updates #25

Workflow file for this run

# This workflow will build a Java project with Maven, 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-maven
name: Build, Test & Deploy to GitHub packages and Maven Central
on:
push:
tags: [ '*' ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- name: Checkout completely
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout with tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Cache Maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2
restore-keys: ${{ runner.os }}-m2
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'zulu'
cache: maven
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.2
- name: Build with Maven
env:
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_PRIVATEKEY: ${{ secrets.GPG_PRIVATEKEY }}
run: mvn -P ci-cd -B clean install site --file pom.xml
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/site/jacoco/jacoco.xml
flags: unittests
fail_ci_if_error: true
verbose: true
- name: Deploy with Maven to GitHub Packages
env:
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_PRIVATEKEY: ${{ secrets.GPG_PRIVATEKEY }}
GITHUB_ACTOR: ${{ github.actor }} # GITHUB_TOKEN is the default env for the password
GITHUB_TOKEN: ${{ github.token }} # GITHUB_TOKEN is the default env for the password
run: |
mvn -B \
-P ci-cd \
--batch-mode \
-DskipTests \
-DaltDeploymentRepository=github::https://maven.pkg.github.com/$GITHUB_REPOSITORY \
--file pom.xml \
deploy
- name: Set up maven for OSSRH deployment
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'zulu'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_PASSWORD # env variable for token in deploy
- name: Deploy with Maven to Maven Central
env:
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GPG_PRIVATEKEY: ${{ secrets.GPG_PRIVATEKEY }}
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
run: |
mvn -B \
-P ci-cd \
--batch-mode \
-DskipTests \
-DaltDeploymentRepository=ossrh::https://oss.sonatype.org/service/local/staging/deploy/maven2/ \
--file pom.xml \
deploy
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "target/params4j*.jar*"
token: ${{ github.token }}
- name: Tidy up old package versions
uses: actions/delete-package-versions@v5
continue-on-error: true
with:
package-name: 'params4j'
package-type: container
min-versions-to-keep: 4
num-old-versions-to-delete: 0
delete-only-pre-release-versions: "true"
- name: Checkout GitHub Pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
- name: Modify GitHub Pages
run: |
env
mkdir -p gh-pages/docs/$GITHUB_REF_NAME
cp -R target/site/* gh-pages/docs/$GITHUB_REF_NAME
for dir in `find gh-pages/docs -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort -r | tail -n +4`; do rm -Rf "gh-pages/docs/$dir"; done
mkdir -p gh-pages/docs/latest
cp -R target/site/* gh-pages/docs/latest
echo "## Parameters 4 Java Releases" > gh-pages/docs/index.md
echo >> gh-pages/docs/index.md
echo "| Release | Site Root | JavaDocs |" >> gh-pages/docs/index.md
for file in `find gh-pages/docs -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | sort -r`; do echo "| ${file##*/} | [${file##*/}/project-info.html](https://${GITHUB_ACTOR}.github.io/${GITHUB_REPOSITORY##*/}/${file##*/}/project-info.html) | [${file##*/}/apidocs/index.html](https://${GITHUB_ACTOR}.github.io/${GITHUB_REPOSITORY##*/}/${file##*/}/apidocs/index.html) | " >> gh-pages/docs/index.md; done
- name: Checkin GitHub Pages
uses: crazy-max/ghaction-github-pages@v4
with:
target_branch: gh-pages
build_dir: gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean up settings.xml
run: |
rm "${HOME}/.m2/settings.xml"