Skip to content

chore(deps): update pre-commit hook commitizen-tools/commitizen to v4… #429

chore(deps): update pre-commit hook commitizen-tools/commitizen to v4…

chore(deps): update pre-commit hook commitizen-tools/commitizen to v4… #429

Workflow file for this run

---
name: Build & Release
on:
push:
branches: ['**']
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
env:
SETTINGS_XML: ${{ github.workspace }}/.mvn/settings.xml
JAVA_VERSION: 17
JAVA_DISTRIBUTION: temurin
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
outputs:
project_version: ${{ steps.project_metadata.outputs.version }}
is_release: ${{ steps.project_metadata.outputs.is_release }}
env:
IO_JFROG_SBB_POLARION_TOKEN: ${{ secrets.IO_JFROG_SBB_POLARION_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
MARKDOWN2HTML_MAVEN_PLUGIN_FAIL_ON_ERROR: true
GITHUB_TOKEN: ${{ github.token }} # Providing this prevents reaching the GitHub request limits
steps:
- name: 📄 Checkout the repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0 # Sonar needs full history
persist-credentials: false
- name: 🧱 Set up JDK and Maven
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: 📝 Extract project metadata
id: project_metadata
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
# Check if it is a release
if [[ ! "${VERSION}" =~ -SNAPSHOT$ ]]; then
IS_RELEASE=true
else
IS_RELEASE=false
fi
{
echo "version=${VERSION}"
echo "is_release=${IS_RELEASE}"
} >> "$GITHUB_OUTPUT"
- name: 🔍 Cache SonarQube packages
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: 📦 Build with Maven for Pushes
if: github.event_name == 'push'
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
run: |
if [ -n "${GITHUB_HEAD_REF}" ]; then
mvn --batch-mode -s "${SETTINGS_XML}" clean verify sonar:sonar -Dsonar.branch.name="${GITHUB_HEAD_REF}"
else
mvn --batch-mode -s "${SETTINGS_XML}" clean verify sonar:sonar
fi
- name: 📦 Build with Maven for PRs
if: github.event_name == 'pull_request'
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
GITHUB_BASE_REF: ${{ github.base_ref }}
GITHUB_PR_NUMBER_REF: ${{ github.event.pull_request.number }}
run: mvn --batch-mode -s "${SETTINGS_XML}" clean verify sonar:sonar -Dsonar.pullrequest.base="${GITHUB_BASE_REF}" -Dsonar.pullrequest.branch="${GITHUB_HEAD_REF}" -Dsonar.pullrequest.key="${GITHUB_PR_NUMBER_REF}"
- name: 📋 Analyze dependencies
run: mvn --batch-mode -s "${SETTINGS_XML}" dependency:analyze
continue-on-error: false
- name: 📦 Upload build artifacts
# needed for uploads to GitHub Releases
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: maven-artifacts
path: |
**/target/*.jar
**/target/*.pom
retention-days: 1
if-no-files-found: error
deploy-github-packages:
needs: build
if: ${{ needs.build.outputs.is_release == 'true' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_REPO_NAME: ${{ github.repository }}
PROJECT_VERSION: ${{ needs.build.outputs.project_version }}
steps:
- name: 📄 Checkout the repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 1
persist-credentials: false
- name: 📥 Download build artifacts
# The artifacts are generated in the 'build' step
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
with:
name: maven-artifacts
path: .
- name: 🧱 Set up JDK and Maven
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
with:
distribution: ${{ env.JAVA_DISTRIBUTION }}
java-version: ${{ env.JAVA_VERSION }}
cache: maven
- name: 📦 Deploy to GitHub Packages
run: |
mvn --batch-mode -s "${SETTINGS_XML}" deploy \
-Dmaven.test.skip=true \
-Dmaven.javadoc.skip=true \
-Dmaven.source.skip=true \
-P deploy-github-packages
- name: 📦 Upload assets to GitHub Release
run: |-
gh release upload "v${PROJECT_VERSION}" "hook-samples/**/target/*-${PROJECT_VERSION}.jar" --clobber
gh release upload "v${PROJECT_VERSION}" "hook-samples-guice/**/target/*-${PROJECT_VERSION}.jar" --clobber
gh release upload "v${PROJECT_VERSION}" "hook-samples-osgi/**/target/*-${PROJECT_VERSION}.jar" --clobber