Create Maven Release #3
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: Create Maven Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| releaseVersion: | |
| description: "Release Version:" | |
| required: true | |
| developmentVersion: | |
| description: "Next Development Version:" | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| # with: | |
| # token: ${{ github.token }} | |
| - name: Set up Java for publishing to Maven Central Repository | |
| uses: actions/setup-java@v2 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| server-id: ossrh | |
| server-username: MAVEN_USERNAME | |
| server-password: MAVEN_PASSWORD | |
| - name: Configure Git User | |
| run: | | |
| git config user.email ${{ github.actor }}@users.noreply.github.com | |
| git config user.name ${{ github.actor }} | |
| - name: Prepare Release | |
| run: mvn -B release:prepare -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} | |
| env: | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: Push Release | |
| run: | | |
| git push | |
| git push --tags | |
| - name: Checkout badges branch to a badges directory nested inside first checkout | |
| uses: actions/checkout@v2 | |
| with: | |
| ref: badges | |
| path: badges | |
| - 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: Packs Jacoco Reports | |
| run: | | |
| rm -rf badges/jacoco | |
| mkdir -p badges/jacoco | |
| echo "GROUP,PACKAGE,CLASS,INSTRUCTION_MISSED,INSTRUCTION_COVERED,BRANCH_MISSED,BRANCH_COVERED,LINE_MISSED,LINE_COVERED,COMPLEXITY_MISSED,COMPLEXITY_COVERED,METHOD_MISSED,METHOD_COVERED" > badges/jacoco-report.csv | |
| find -name 'jacoco.csv' -exec sed '1d' {} \; >> badges/jacoco-report.csv | |
| tar -c `find -name jacoco.csv` `find -name jacoco.exec` `find -name jacoco.xml` | tar -C badges/jacoco -x | |
| - name: Commit and push the coverage badges and summary file | |
| if: ${{ github.event_name != 'pull_request' }} | |
| run: | | |
| echo $(ls -l) | |
| cd badges | |
| if [[ `git status --porcelain` ]]; then | |
| git config --global user.name 'github-agit pctions' | |
| git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
| git add *.svg *.json jacoco-report.csv jacoco/* | |
| git commit -m "coverage = ${{ steps.jacoco.outputs.coverage }} branches = ${{ steps.jacoco.outputs.branches }}" *.svg *.json jacoco-report.csv jacoco/* | |
| git push | |
| git tag coverage_badges_${{github.event.release.tag_name}} | |
| git push --tags | |
| fi |