1- name : Build & Publish on Schema Change
1+ name : Build & Publish Java Package
22
33on :
44 push :
55 branches :
66 - main
77 paths :
8- - " schemas/**"
98 - " java/**"
10- - " java/pom.xml"
119 workflow_dispatch :
1210
1311jobs :
2523 steps :
2624 - name : Checkout Code
2725 uses : actions/checkout@v4
26+ with :
27+ fetch-depth : 0
2828
2929 - name : Set up JDK
3030 uses : actions/setup-java@v4
@@ -50,36 +50,29 @@ jobs:
5050 </settings>
5151 EOF
5252
53- - name : Read Schema Version
54- id : schema
53+ - name : Read Version
54+ id : version
5555 run : |
56- SCHEMA_VERSION=$(cat ../schemas/VERSION | tr -d '\n')
57- echo "Using schema version: $SCHEMA_VERSION"
58- echo "schema_version=$SCHEMA_VERSION" >> $GITHUB_OUTPUT
56+ VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
57+ echo "value=$VERSION" >> $GITHUB_OUTPUT
5958
60- - name : Read Implementation Version
61- id : impl
59+ - name : Generate Changelog
60+ id : changelog
6261 run : |
63- IMPL_VERSION=$(mvn help:evaluate -Dexpression=project .version -q -DforceStdout)
64- echo "Using implementation version: $IMPL_VERSION"
65- echo "impl_version=$IMPL_VERSION" >> $GITHUB_OUTPUT
66-
67- - name : Create Combined Version
68- id : version
69- run : |
70- COMBINED_VERSION="${{ steps.impl.outputs.impl_version }}-schema-${{ steps.schema.outputs.schema_version }}"
71- echo "Using combined version: $COMBINED_VERSION"
72- echo "combined_version=$COMBINED_VERSION " >> $GITHUB_OUTPUT
62+ TAG="java-v${{ steps .version.outputs.value }}"
63+ if git rev-parse "$TAG" >/dev/null 2>&1; then
64+ LOG=$(git log "$TAG"..HEAD --oneline -- ../java)
65+ else
66+ LOG=$(git log --oneline -20 -- ../java)
67+ fi
68+ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
69+ echo "body<<$EOF" >> $GITHUB_OUTPUT
70+ echo "$LOG" >> $GITHUB_OUTPUT
71+ echo "$EOF " >> $GITHUB_OUTPUT
7372
7473 - name : Build with Maven
7574 run : mvn clean package
7675
77- - name : Rename Artifacts for GitHub Release
78- run : |
79- mv target/pacts-${{ steps.impl.outputs.impl_version }}.jar target/pacts-${{ steps.version.outputs.combined_version }}.jar
80- mv target/pacts-${{ steps.impl.outputs.impl_version }}-sources.jar target/pacts-${{ steps.version.outputs.combined_version }}-sources.jar
81- mv target/pacts-${{ steps.impl.outputs.impl_version }}-javadoc.jar target/pacts-${{ steps.version.outputs.combined_version }}-javadoc.jar
82-
8376 - name : Publish to GitHub Packages
8477 env :
8578 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
@@ -89,17 +82,15 @@ jobs:
8982 - name : Create GitHub Release
9083 uses : softprops/action-gh-release@v2
9184 with :
92- tag_name : java-v${{ steps.version.outputs.combined_version }}
93- name : Java Package v${{ steps.version.outputs.combined_version }}
85+ tag_name : java-v${{ steps.version.outputs.value }}
86+ name : Java v${{ steps.version.outputs.value }}
9487 body : |
95- Java package release for version ${{ steps.version.outputs.combined_version }}
88+ ## Java Package v ${{ steps.version.outputs.value }}
9689
97- Changes:
98- - Implementation version: ${{ steps.impl.outputs.impl_version }}
99- - Schema version: ${{ steps.schema.outputs.schema_version }}
90+ ${{ steps.changelog.outputs.body }}
10091 files : |
101- java/target/pacts-${{ steps.version.outputs.combined_version }}.jar
102- java/target/pacts-${{ steps.version.outputs.combined_version }}-sources.jar
103- java/target/pacts-${{ steps.version.outputs.combined_version }}-javadoc.jar
92+ java/target/pacts-${{ steps.version.outputs.value }}.jar
93+ java/target/pacts-${{ steps.version.outputs.value }}-sources.jar
94+ java/target/pacts-${{ steps.version.outputs.value }}-javadoc.jar
10495 env :
10596 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments