bld_mvn #28
This file contains hidden or 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: bld_mvn | |
| permissions: | |
| checks: write | |
| contents: read | |
| issues: read | |
| pull-requests: write | |
| on: | |
| workflow_call: | |
| inputs: | |
| version_tag: | |
| description: 'Version tag to use: (bump must also be set to none to keep a specific version' | |
| required: false | |
| default: 'latest' | |
| type: string | |
| bump: | |
| description: 'whether to bump the version number by a major minor patch' | |
| required: false | |
| default: 'patch' | |
| type: string | |
| ref: | |
| description: 'git reference to use with the checkout use default_branch to have that calculated' | |
| required: false | |
| default: "default" | |
| type: string | |
| seed_maven_cache: | |
| description: Whether to seed cache | |
| type: boolean | |
| required: false | |
| default: true | |
| install_maven_dependencies: | |
| description: Whether to install dependencies or use a previous cache | |
| type: boolean | |
| required: false | |
| default: true | |
| deploy: | |
| description: Whether to deploy the build to artifact repo | |
| type: boolean | |
| required: false | |
| default: true | |
| java_version: | |
| description: 'JDK version to build with' | |
| required: false | |
| default: '11' | |
| type: string | |
| workflow_dispatch: | |
| inputs: | |
| version_tag: | |
| description: 'Version tag to use: (bump must also be set to none to keep a specific version' | |
| required: false | |
| default: 'latest' | |
| type: string | |
| bump: | |
| description: | | |
| How to optionally bump the semver version ( Major.Minor.Patch ) : git log will be searched for | |
| '#major #minor #patch' or feat/ or fix/ branch names to optionally override the bump. Set to none to keep a specific version | |
| required: false | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| - none | |
| type: choice | |
| ref: | |
| description: 'git reference to use with the checkout use default_branch to have that calculated' | |
| required: false | |
| default: "default" | |
| type: string | |
| seed_maven_cache: | |
| description: Whether to seed cache | |
| type: boolean | |
| required: false | |
| default: true | |
| install_maven_dependencies: | |
| description: Whether to install dependencies or use a previous cache | |
| type: boolean | |
| required: false | |
| default: true | |
| deploy: | |
| description: Whether to deploy the build to artifact repo | |
| type: boolean | |
| required: false | |
| default: true | |
| java_version: | |
| description: 'JDK version to build with' | |
| required: false | |
| default: '11' | |
| type: choice | |
| options: | |
| - '11' | |
| - '21' | |
| jobs: | |
| bld_mvn: | |
| strategy: | |
| matrix: | |
| include: | |
| - project: orcid-message-listener | |
| - project: orcid-activemq | |
| - project: orcid-api-web | |
| - project: orcid-internal-api | |
| - project: orcid-pub-web | |
| - project: orcid-scheduler-web | |
| - project: orcid-web | |
| - project: orcid-utils | |
| - project: orcid-core | |
| - project: orcid-persistence | |
| - project: orcid-api-common | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 | |
| with: | |
| egress-policy: audit | |
| - name: git-checkout-ref-action | |
| id: ref | |
| uses: ORCID/git-checkout-ref-action@4258c0cbe4b164e410d0263416034787fb300f26 # main | |
| with: | |
| default_branch: ${{ github.event.repository.default_branch }} | |
| ref: ${{ inputs.ref }} | |
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 | |
| with: | |
| ref: ${{ steps.ref.outputs.ref }} | |
| # checkout some history so we can scan commits for bump messages | |
| # NOTE: history does not include tags! | |
| fetch-depth: 100 | |
| - name: find next version | |
| id: version | |
| uses: ORCID/version-bump-action@75233259407ae3728171973d09bc66fcf4b15b6a # main | |
| with: | |
| version_tag: ${{ inputs.version_tag }} | |
| bump: ${{ inputs.bump }} | |
| - name: Set up Open JDK | |
| uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0 | |
| with: | |
| distribution: 'temurin' | |
| java-version: ${{ inputs.java_version }} | |
| ###################################################################################################################### | |
| # handle restoring a custom gha cache | |
| - name: if not installing dependencies restore special previous git_sha cache | |
| if: ${{ ! inputs.install_maven_dependencies }} | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ steps.version.outputs.version_tag_numeric }}-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ steps.version.outputs.version_tag_numeric }}-${{ github.sha }} | |
| - name: bump version of the parent pom and connected projects | |
| if: ${{ ! inputs.install_maven_dependencies }} | |
| run: | | |
| mvn -T 1C --batch-mode versions:set -DskipTests \ | |
| -DnewVersion="$version_tag_numeric" -DgenerateBackupPoms=false | |
| env: | |
| version_tag_numeric: "${{ steps.version.outputs.version_tag_numeric }}" | |
| ######################################################################################## | |
| - name: if installing dependencies use a standard cache key name | |
| if: ${{ inputs.install_maven_dependencies }} | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-seed-cache | |
| restore-keys: | | |
| ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-seed-cache | |
| - name: seed_maven_cache | |
| if: ${{ inputs.seed_maven_cache }} | |
| id: cache | |
| uses: ORCID/ORCID-Source-cache-action@9831e0ffb2e9db46bffa6bb55fb897d159da5668 # main | |
| with: | |
| version_tag_numeric: ${{ steps.version.outputs.version_tag_numeric }} | |
| - name: install_dependencies and bump version | |
| if: ${{ inputs.install_maven_dependencies }} | |
| id: install_dependencies | |
| uses: ORCID/ORCID-Source-dependencies-action@e470d485ef8dc69858100998d77d03ccefb06ef1 # main | |
| with: | |
| version_tag_numeric: ${{ steps.version.outputs.version_tag_numeric }} | |
| - name: build our project | |
| run: | | |
| mvn -T 1C --batch-mode -am package -DskipTests \ | |
| -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ | |
| --projects "$project" | |
| echo "------------------------------------------------------" | |
| find . -name '*.war' | |
| find . -name '*.jar' | |
| env: | |
| project: "${{ matrix.project }}" | |
| # | |
| # orcid-web customization | |
| # | |
| - name: setup node for angular static file | |
| if: ${{ matrix.project == 'orcid-web' }} | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: 18.7.0 | |
| - name: build angular parts if we are building orcid-web | |
| if: ${{ matrix.project == 'orcid-web' }} | |
| run: | | |
| echo "Build angular_orcid_generated.js" | |
| cd orcid-nodejs | |
| mvn -T 1C --batch-mode -P ci clean compile \ | |
| -Dnodejs.workingDirectory="${{ github.workspace }}/orcid-web/src/main/webapp/static/javascript/ng1Orcid" \ | |
| -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn | |
| echo "Copying angular_orcid_generated to its final destination" | |
| cp ${{ github.workspace }}/orcid-web/src/main/webapp/static/javascript/ng1Orcid/angular_orcid_generated.js ${{ github.workspace }}/orcid-web/target/orcid-web/static/javascript/ng1Orcid/ | |
| echo "Packaging orcid-web" | |
| rm -f ${{ github.workspace }}/orcid-web/target/orcid-web.war | |
| cd ${{ github.workspace }}/orcid-web/target/orcid-web | |
| # have a file on the webserver we can hit | |
| echo "$version_tag_numeric" > ${{ github.workspace }}/orcid-web/target/orcid-web/static/version | |
| echo "Creating the war file" | |
| jar -cf orcid-web.war . | |
| # check_error "Creating the orcid-web.war file" | |
| echo "Moving war file to the target folder" | |
| cp orcid-web.war ${{ github.workspace }}/orcid-web/target/ | |
| echo "orcid-web.war is ready" | |
| env: | |
| version_tag_numeric: "${{ steps.version.outputs.version_tag_numeric }}" | |
| project: "${{ matrix.project }}" | |
| ################################################################################################################## | |
| - name: deploy war file | |
| if: ${{ inputs.deploy }} | |
| run: | | |
| mvn --batch-mode \ | |
| --settings settings-deploy.xml \ | |
| --file "${project}/pom.xml" \ | |
| -Dmaven.test.skip \ | |
| -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ | |
| -DaltReleaseDeploymentRepository="github::${ARTIFACT_URL}${ARTIFACT_REPO_PATH}" \ | |
| deploy -Dmaven.test.skip | |
| env: | |
| GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
| ARTIFACT_URL: "${{ secrets.ARTIFACT_URL }}" | |
| ARTIFACT_REPO_PATH: "${{ secrets.ARTIFACT_REPO_PATH }}" | |
| ARTIFACT_USER: "${{ secrets.ARTIFACT_USER }}" | |
| ARTIFACT_PASSWORD: "${{ secrets.ARTIFACT_PASSWORD }}" | |
| project: "${{ matrix.project }}" | |