Skip to content

Commit a7db482

Browse files
committed
refactors GH Actions for namespace io.zenwave360
1 parent f532859 commit a7db482

File tree

5 files changed

+122
-34
lines changed

5 files changed

+122
-34
lines changed

.github/workflows/main.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Verify Main and Publish Coverage
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
# pull_request:
7+
# branches: [ '**' ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Set up the Java JDK
19+
uses: actions/setup-java@v2
20+
with:
21+
java-version: '17'
22+
distribution: 'adopt'
23+
24+
- name: Verify and Publish Coverage
25+
run: mvn verify
26+
27+
- name: Checkout badges branch to a badges directory nested inside first checkout
28+
uses: actions/checkout@v2
29+
with:
30+
ref: badges
31+
path: badges
32+
33+
- name: Generate JaCoCo Badge
34+
id: jacoco
35+
uses: cicirello/jacoco-badge-generator@v2
36+
with:
37+
badges-directory: badges
38+
generate-branches-badge: true
39+
generate-summary: true
40+
41+
- name: Log coverage percentage
42+
run: |
43+
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
44+
echo "branch coverage = ${{ steps.jacoco.outputs.branches }}"
45+
46+
- name: Packs Jacoco Reports
47+
run: |
48+
rm -rf badges/jacoco
49+
mkdir -p badges/jacoco
50+
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
51+
find -name 'jacoco.csv' -exec sed '1d' {} \; >> badges/jacoco-report.csv
52+
tar -c `find -name jacoco.csv` `find -name jacoco.exec` `find -name jacoco.xml` | tar -C badges/jacoco -x
53+
54+
55+
- name: Commit and push the coverage badges and summary file
56+
if: ${{ github.event_name != 'pull_request' }}
57+
run: |
58+
echo $(ls -l)
59+
cd badges
60+
if [[ `git status --porcelain` ]]; then
61+
git config --global user.name 'github-agit pctions'
62+
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
63+
git add *.svg *.json jacoco-report.csv jacoco/*
64+
git commit -m "coverage = ${{ steps.jacoco.outputs.coverage }} branches = ${{ steps.jacoco.outputs.branches }}" *.svg *.json jacoco-report.csv jacoco/*
65+
git push
66+
fi
67+

.github/workflows/prepare-maven-release.yml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,40 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v2
17-
# with:
18-
# token: ${{ github.token }}
17+
1918
- name: Set up Java for publishing to Maven Central Repository
2019
uses: actions/setup-java@v2
2120
with:
2221
java-version: '17'
23-
distribution: 'adopt'
24-
server-id: ossrh
25-
server-username: MAVEN_USERNAME
26-
server-password: MAVEN_PASSWORD
22+
distribution: 'temurin'
2723

2824
- name: Configure Git User
2925
run: |
3026
git config user.email ${{ github.actor }}@users.noreply.github.com
3127
git config user.name ${{ github.actor }}
3228
3329
- name: Prepare Release
34-
run: mvn -B release:prepare -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }}
30+
run: |
31+
mvn -B release:prepare -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }}
32+
mvn -B release:clean
3533
env:
3634
GITHUB_ACTOR: ${{ github.actor }}
3735
GITHUB_TOKEN: ${{ github.token }}
3836

39-
- name: Push Release
40-
run: |
41-
git push
42-
git push --tags
37+
- name: Create Pull Request (Main)
38+
id: cpr
39+
uses: peter-evans/create-pull-request@v5
40+
with:
41+
commit-message: 'Release ${{ github.event.inputs.releaseVersion }}'
42+
branch: release/${{ github.event.inputs.releaseVersion }}
43+
title: 'Release ${{ github.event.inputs.releaseVersion }}'
44+
body: 'Release ${{ github.event.inputs.releaseVersion }}'
45+
labels: 'release'
46+
47+
- name: Enable Pull Request Automerge (Main)
48+
run: gh pr merge --merge --auto --delete-branch "${{ steps.cpr.outputs.pull-request-number }}"
49+
env:
50+
GH_TOKEN: ${{ github.token }}
51+
52+
- name: Push Release Tag
53+
run: git push --tags

.github/workflows/publish-maven-central.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,40 @@ name: Publish to Maven Central
22
on:
33
release:
44
types: [created]
5+
workflow_dispatch:
6+
inputs:
7+
tag:
8+
description: 'Tag to check out'
9+
required: true
10+
default: 'main'
511
jobs:
612
publish:
713
runs-on: ubuntu-latest
814
steps:
915
- uses: actions/checkout@v2
16+
with:
17+
ref: ${{ github.event.inputs.tag || github.event.release.tag_name }}
18+
1019
- name: Set up Java for publishing to Maven Central Repository
1120
uses: actions/setup-java@v2
1221
with:
1322
java-version: '17'
14-
distribution: 'adopt'
15-
server-id: ossrh
23+
distribution: 'temurin'
24+
server-id: central
1625
server-username: MAVEN_USERNAME
1726
server-password: MAVEN_PASSWORD
27+
28+
# - name: Enforce Release Version
29+
# run: mvn enforcer:enforce@enforce-release-version
30+
1831
- name: Publish to the Maven Central Repository
1932
run: mvn --batch-mode deploy -DdeployAtEnd=true -Dmaven.javadoc.skip=false
2033
env:
21-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
22-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
34+
MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
35+
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }}
2336
SIGN_KEY: ${{ secrets.SIGN_KEY }}
2437
SIGN_KEY_PASS: ${{ secrets.SIGN_KEY_PASS }}
2538

26-
27-
2839
- name: Checkout badges branch to a badges directory nested inside first checkout
2940
uses: actions/checkout@v2
3041
with:
@@ -57,13 +68,14 @@ jobs:
5768
if: ${{ github.event_name != 'pull_request' }}
5869
run: |
5970
echo $(ls -l)
71+
TAG_NAME=${{ github.event.release.tag_name || github.run_id }}
6072
cd badges
6173
if [[ `git status --porcelain` ]]; then
6274
git config --global user.name 'github-agit pctions'
6375
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
6476
git add *.svg *.json jacoco-report.csv jacoco/*
6577
git commit -m "coverage = ${{ steps.jacoco.outputs.coverage }} branches = ${{ steps.jacoco.outputs.branches }}" *.svg *.json jacoco-report.csv jacoco/*
6678
git push
67-
git tag coverage_badges_${{github.event.release.tag_name}}
79+
git tag coverage_badges_${TAG_NAME}
6880
git push --tags
6981
fi

.github/workflows/build.yml renamed to .github/workflows/publish-maven-snapshots.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: Build and Publish Maven Snapshots
22

33
on:
44
push:
@@ -15,28 +15,26 @@ jobs:
1515
- name: Checkout
1616
uses: actions/checkout@v2
1717

18-
- name: Set up the Java JDK
18+
- name: Set up Java for publishing to Maven Central Repository
1919
uses: actions/setup-java@v2
2020
with:
2121
java-version: '17'
22-
distribution: 'adopt'
23-
server-id: ossrh
22+
distribution: 'temurin'
23+
server-id: central
2424
server-username: MAVEN_USERNAME
2525
server-password: MAVEN_PASSWORD
2626

27-
- name: Build and Publish SNAPSHOT to the Maven Central
28-
if: ${{ github.event_name == 'push' }}
29-
run: mvn -B verify deploy -DdeployAtEnd=true
27+
- name: Enforce Snapshot Version
28+
run: mvn enforcer:enforce@enforce-snapshot-version
29+
30+
- name: Publish to the Maven Central Repository
31+
run: mvn --batch-mode deploy -DdeployAtEnd=true -Dmaven.javadoc.skip=false
3032
env:
31-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
32-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
33+
MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
34+
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }}
3335
SIGN_KEY: ${{ secrets.SIGN_KEY }}
3436
SIGN_KEY_PASS: ${{ secrets.SIGN_KEY_PASS }}
3537

36-
# - name: Build and Verify
37-
# if: ${{ github.event_name == 'pull_request' }}
38-
# run: mvn -B verify
39-
4038
- name: Generate JaCoCo Badge
4139
id: jacoco
4240
uses: cicirello/jacoco-badge-generator@v2
@@ -61,5 +59,5 @@ jobs:
6159
gh pr comment ${{github.event.pull_request.number}} -b "${BODY}"
6260
continue-on-error: true
6361
env:
64-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
6563

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ ZenWave Domain Model Language
44

55
[![Maven Central](https://img.shields.io/maven-central/v/io.zenwave360.sdk/zdl-jvm.svg?label=Maven%20Central&logo=apachemaven)](https://search.maven.org/artifact/io.zenwave360.sdk/zdl-jvm)
66
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/ZenWave360/zdl-jvm?logo=GitHub)](https://github.com/ZenWave360/zdl-jvm/releases)
7-
[![build](https://github.com/ZenWave360/zdl-jvm/workflows/Build/badge.svg)](https://github.com/ZenWave360/zdl-jvm/actions/workflows/build.yml)
7+
[![build](https://github.com/ZenWave360/zdl-jvm/workflows/Build%20and%20Publish%20Maven%20Snapshots/badge.svg)](https://github.com/ZenWave360/zdl-jvm/actions/workflows/publish-maven-snapshots.yml)
88
[![coverage](https://raw.githubusercontent.com/ZenWave360/zdl-jvm/badges/jacoco.svg)](https://github.com/ZenWave360/zdl-jvm/actions/workflows/build.yml)
9-
[![branches coverage](https://raw.githubusercontent.com/ZenWave360/zdl-jvm/badges/branches.svg)](https://github.com/ZenWave360/zdl-jvm/actions/workflows/build.yml)
9+
[![branches coverage](https://raw.githubusercontent.com/ZenWave360/zdl-jvm/badges/branches.svg)](https://github.com/ZenWave360/zdl-jvm/actions/workflows/main.yml)
1010
[![GitHub](https://img.shields.io/github/license/ZenWave360/zdl-jvm)](https://github.com/ZenWave360/zdl-jvm/blob/main/LICENSE)
1111

1212
> Since version 1.4.0 groupId was changed to `io.zenwave360.sdk`

0 commit comments

Comments
 (0)