Skip to content

lf-api-client-core-java-CI #274

lf-api-client-core-java-CI

lf-api-client-core-java-CI #274

Workflow file for this run

name: lf-api-client-core-java-CI
on:
push:
branches: ['\d+.x']
pull_request:
branches: ['\d+.x']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
VERSION_PREFIX: '2.2.2'
GITHUB_PAGES_BRANCH: 'gh-pages'
jobs:
build-n-test:
runs-on: ubuntu-latest
env:
ACCESS_KEY: ${{ secrets.DEV_CA_PUBLIC_USE_INTEGRATION_TEST_ACCESS_KEY }}
SERVICE_PRINCIPAL_KEY: ${{ secrets.DEV_CA_PUBLIC_USE_TESTOAUTHSERVICEPRINCIPAL_SERVICE_PRINCIPAL_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Build with Maven
run: mvn -B package -Dmaven.test.skip=true --file pom.xml
- name: Run unit tests
run: mvn -Dtest=com.laserfiche.api.client.unit.*Test test
- name: Publish unit test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: target/surefire-reports/*.xml
check_name: unit-test-results
- name: Delete test reports
run: rm -rf target/surefire-reports/*.xml
- name: Run integration tests on cloud
id: integration-test-cloud
run: mvn test -Dgroups=Cloud
- name: Publish cloud test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: target/surefire-reports/*.xml
check_name: integration-test-results-cloud
- name: Delete test reports
run: rm -rf target/surefire-reports/*.xml
- name: Run integration tests on self-hosted
id: integration-test-self-hosted
if: always() && (steps.integration-test-cloud.outcome == 'success' || steps.integration-test-cloud.outcome == 'failure')
env:
REPOSITORY_ID: ${{ secrets.APISERVER_REPOSITORY_ID }}
APISERVER_USERNAME: ${{ secrets.APISERVER_USERNAME }}
APISERVER_PASSWORD: ${{ secrets.APISERVER_PASSWORD }}
APISERVER_REPOSITORY_API_BASE_URL: ${{ secrets.APISERVER_REPOSITORY_API_BASE_URL }}
run: mvn test -Dgroups=SelfHosted
- name: Publish self-hosted test results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: target/surefire-reports/*.xml
check_name: integration-test-results-self-hosted
build-documentation:
runs-on: ubuntu-latest
needs: [build-n-test]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Create temporary directory
run: mkdir -p ./docs_temp/${{ github.ref_name }}
- name: Generate Javadoc
run: mvn javadoc:javadoc
- name: Move javadoc files to temporary directory
run: mv ${{ github.workspace }}/target/site/ ${{ github.workspace }}/docs_temp/${{ github.ref_name }}
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: documentation-artifact
# A file, directory or wildcard pattern that describes what to upload
path: ${{ github.workspace }}/docs_temp/${{ github.ref_name }}/site/apidocs
- name: Delete temporary directory
run: rm -r ./docs_temp
publish-preview-package:
runs-on: ubuntu-latest
environment: preview
if: ${{ github.run_attempt != 1 }}
needs: [build-n-test, build-documentation] # wait for build to finish
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Import GPG key
run: |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
env:
GPG_PRIVATE_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
- name: Set up Apache Maven Central
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
server-id: central
server-username: ${{ secrets.MAVEN_USERNAME }}
server-password: ${{ secrets.MAVEN_PASSWORD }}
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
gpg-passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
- name: Set Java Package Version environment
run: echo "PACKAGE_VERSION=${{ env.VERSION_PREFIX }}" >> $GITHUB_ENV
- name: Set Java Package Version
run: mvn versions:set -DnewVersion=${{ env.PACKAGE_VERSION }}
- name: Publish to Sonatype
run: mvn clean deploy -Dmaven.test.skip=true -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
env:
GPG_TTY: ${{ env.GPG_TTY }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
- name: Tag commit
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ env.PACKAGE_VERSION }}
commit_sha: ${{ github.sha }}
message: Workflow run ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
publish-production-package:
runs-on: ubuntu-latest
environment: production
if: ${{ github.run_attempt != 1 }}
needs: [build-n-test, build-documentation] # wait for build to finish
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Build with Maven
run: mvn -B package -Dmaven.test.skip=true --file pom.xml
- name: Set up Apache Maven Central
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
server-id: ossrh
server-username: ${{ secrets.MAVEN_USERNAME }}
server-password: ${{ secrets.MAVEN_PASSWORD }}
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Set Java Package Version environment
run: echo "PACKAGE_VERSION=${{ env.VERSION_PREFIX }}" >> $GITHUB_ENV
- name: Set Java Package Version
run: mvn versions:set -DnewVersion=${{ env.PACKAGE_VERSION }}
- name: Publish to Maven Central
run: mvn clean deploy -P release -Dmaven.test.skip=true -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
- name: Tag commit
uses: rickstaa/action-create-tag@v1
with:
tag: ${{ env.PACKAGE_VERSION }}
commit_sha: ${{ github.sha }}
message: Workflow run ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
publish-documentation:
runs-on: ubuntu-latest
timeout-minutes: 10
environment: github-pages
needs: [publish-production-package]
steps:
- name: Set DOCUMENTATION_VERSION environment variable
run: |
if [[ '${{ github.event_name }}' == 'pull_request' ]]; then
echo 'DOCUMENTATION_VERSION=${{ github.base_ref }}' >> $GITHUB_ENV
elif [[ '${{ github.ref_protected }}' == 'true' && '${{ github.ref_type }}' == 'branch' ]]; then
echo 'DOCUMENTATION_VERSION=${{ github.ref_name }}' >> $GITHUB_ENV
else
echo '::error::Unable to publish documentation for the current branch.'
exit 1
fi
- name: Print DOCUMENTATION_VERSION environment variable
run: |
echo 'Publishing documentation to ${{ env.GITHUB_PAGES_BRANCH }} for ${{ env.DOCUMENTATION_VERSION }}.'
- uses: actions/checkout@v4
with:
ref: ${{ env.GITHUB_PAGES_BRANCH }}
- name: Delete documentation directory
run: rm -f -r ./docs/${{ env.DOCUMENTATION_VERSION }}
- name: Create documentation directory
run: mkdir -p ./docs/${{ env.DOCUMENTATION_VERSION }}
- name: Download documentation build artifact
uses: actions/download-artifact@v4
with:
name: documentation-artifact
path: ./docs/${{ env.DOCUMENTATION_VERSION }}
- name: Create Pull Request
uses: peter-evans/[email protected]
with:
branch: ${{ env.GITHUB_PAGES_BRANCH }}-${{ env.DOCUMENTATION_VERSION }}-patch
delete-branch: true
title: 'Automated documentation update for ${{ env.DOCUMENTATION_VERSION }} by action ${{ github.run_id }}'
commit-message: 'Automated documentation update for ${{ env.DOCUMENTATION_VERSION }} by action ${{ github.run_id }}'
body: 'Automated documentation update for ${{ env.DOCUMENTATION_VERSION }} by action ${{ github.run_id }}'
assignees: ${{ github.actor }}