Skip to content

bld_mvn

bld_mvn #2

Workflow file for this run

name: bld_mvn
permissions:
checks: write
contents: read
issues: read
pull-requests: write
on:
workflow_call:
inputs:
version_tag:
description: 'Name of the tag to build'
required: false
default: 'latest'
type: string
bump:
description: 'whether to bump the version number by a major minor patch amount or none'
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
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
jobs:
bld_mvn:
runs-on: ubuntu-latest
steps:
- name: git-checkout-ref-action
id: ref
uses: ORCID/git-checkout-ref-action@main
with:
default_branch: ${{ github.event.repository.default_branch }}
ref: ${{ inputs.ref }}
- uses: actions/checkout@v4
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@main
with:
version_tag: ${{ inputs.version_tag }}
bump: ${{ inputs.bump }}
- name: Set up Open JDK 11
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: show path
run: |
echo "$PATH"
which java
echo "$JAVA_HOME"
echo "$tag_numeric"
echo "$project"
ls -la
shell: bash
env:
version_tag_numeric: '${{ steps.version.outputs.version_tag_numeric }}'
project: prod
- name: bump version using prod profile
run: |
mvn -T 1C --batch-mode versions:set \
-DnewVersion="$version_tag_numeric" -DgenerateBackupPoms=false --activate-profiles prod -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
env:
version_tag_numeric: '${{ steps.version.outputs.version_tag_numeric }}'
- name: check some build related things
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git --version
git status
git diff
git rev-parse --abbrev-ref HEAD
- name: build our project
run: |
mvn -T 1C --batch-mode \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
--file "pom.xml" \
--activate-profiles prod -Dnodejs.workingDirectory=. \
package -Dmaven.test.skip
echo "------------------------------------------------------"
find . -name '*.war'
find . -name '*.jar'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- name: deploy same artifact for all environments
run: |
WAR_FILE="target/orcid-web-frontend-prod.war"
REPO_URL="${ARTIFACT_URL}${ARTIFACT_REPO_PATH}"
for artifact_id in orcid-web-frontend-prod orcid-web-frontend-sandbox orcid-web-frontend-qa orcid-web-frontend-int; do
mvn -B deploy:deploy-file \
--settings settings-deploy.xml \
-Durl="${REPO_URL}" \
-DrepositoryId=github \
-DgroupId=org.orcid \
-DartifactId="${artifact_id}" \
-Dversion="${{ steps.version.outputs.version_tag_numeric }}" \
-Dpackaging=war \
-Dfile="${WAR_FILE}" \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
done
env:
ARTIFACT_URL: ${{ secrets.ARTIFACT_URL }}
ARTIFACT_REPO_PATH: ${{ secrets.ARTIFACT_REPO_PATH }}
ARTIFACT_USER: ${{ secrets.ARTIFACT_USER }}
ARTIFACT_PASSWORD: ${{ secrets.ARTIFACT_PASSWORD }}