Skip to content

move central-publishing-maven-plugin out of profile #30

move central-publishing-maven-plugin out of profile

move central-publishing-maven-plugin out of profile #30

Workflow file for this run

name: Build
on:
push:
branches: [ develop, next ]
# pull_request:
# branches: [ '**' ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up the Java JDK
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Build and Deploy Snapshots to a GitHub Branch
env:
GH_ACTOR: ${{ secrets.GH_ACTOR }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_SNAPSHOTS_REPO: "ZenWave360/maven-snapshots"
run: |
# Set up a local repository branch for Maven deployment
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
# Clone the target branch for deployment
git clone --branch main "https://${GH_ACTOR}:${GH_TOKEN}@github.com/${GH_SNAPSHOTS_REPO}.git" target-branch
# Calculate the Maven coordinates and Target Branch
GROUP_ID=$(mvn help:evaluate -Dexpression=project.groupId -q -DforceStdout)
ARTIFACT_ID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
STAGING_BRANCH="staging/$GROUP_ID/$ARTIFACT_ID/$VERSION/$(date -u +"%Y%m%d.%H%M%S%3N")"
# Build the project and deploy to the local repo branch
mvn clean deploy -DskipPublishing=true -DaltDeploymentRepository=snapshot-repo::default::file://$(pwd)/target-branch/
# Push the updated snapshots to the branch
cd target-branch
git add -A
git commit -m "Deploy $GROUP_ID:$ARTIFACT_ID:$VERSION" || echo "No changes to commit"
git checkout -b "$STAGING_BRANCH"
git push -u origin "$STAGING_BRANCH"
# Create a pull request using GitHub CLI
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
gh pr create \
--title "Deploy $GROUP_ID:$ARTIFACT_ID:$VERSION" \
--body "This PR deploys $GROUP_ID:$ARTIFACT_ID:$VERSION. [View the action run]($RUN_URL)" \
--base main --head "$STAGING_BRANCH"
- name: Generate JaCoCo Badge
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
with:
badges-directory: badges
generate-branches-badge: true
generate-summary: true
- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
- name: Comment on PR with coverage percentages
if: ${{ github.event_name == 'pull_request' }}
run: |
REPORT=$(<badges/zenwave-sdk-cli/coverage-summary.json)
COVERAGE=$(jq -r '.coverage' <<< "$REPORT")%
BRANCHES=$(jq -r '.branches' <<< "$REPORT")%
NEWLINE=$'\n'
BODY="## JaCoCo Test Coverage Summary Statistics (zenwave-sdk-cli)${NEWLINE}* __Coverage:__ ${COVERAGE}${NEWLINE}* __Branches:__ ${BRANCHES}"
gh pr comment ${{github.event.pull_request.number}} -b "${BODY}"
continue-on-error: true
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}