Skip to content

Commit c3dc2da

Browse files
authored
DATAGO-70348: Publish quarkus to Maven Central (#57)
2 parents 2707c64 + 099002f commit c3dc2da

File tree

17 files changed

+295
-113
lines changed

17 files changed

+295
-113
lines changed

.github/workflows/build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- "main"
7+
- 'release/*'
78
paths-ignore:
89
- '.gitignore'
910
- 'CODEOWNERS'

.github/workflows/pre-release.yml

-33
This file was deleted.

.github/workflows/release.yml

+124-35
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,163 @@
11
name: Quarkiverse Release
22

33
on:
4-
pull_request:
5-
types: [closed]
6-
paths:
7-
- '.github/project.yml'
4+
workflow_dispatch:
5+
inputs:
6+
releaseVersion:
7+
description: "Version to use when preparing a release. Use `auto` to use the latest version from the pom.xml."
8+
required: true
9+
default: "auto"
10+
sourceBranch:
11+
description: "Which branch contains the previous release version."
12+
default: "main"
813

914
concurrency:
10-
group: ${{ github.workflow }}-${{ github.ref }}
11-
cancel-in-progress: true
15+
group: "quarkiverse-release"
16+
cancel-in-progress: false
1217

1318
defaults:
1419
run:
1520
shell: bash
21+
permissions:
22+
contents: write
23+
packages: write
24+
checks: write
25+
1626

1727
jobs:
1828
release:
1929
runs-on: ubuntu-latest
2030
name: release
21-
if: ${{github.event.pull_request.merged == true}}
22-
2331
steps:
24-
- uses: radcortez/project-metadata-action@main
25-
name: Retrieve project metadata
26-
id: metadata
32+
- uses: actions/checkout@v4
2733
with:
28-
github-token: ${{secrets.GITHUB_TOKEN}}
29-
metadata-file-path: '.github/project.yml'
30-
31-
- uses: actions/checkout@v3
34+
ref: ${{ github.event.inputs.sourceBranch }}
3235

3336
- name: Import GPG key
34-
id: import_gpg
35-
uses: crazy-max/ghaction-import-gpg@v6
37+
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 #v6.1.0
3638
with:
3739
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
38-
passphrase: ${{ secrets.GPG_PASSPHRASE }}
39-
40+
passphrase: ${{ secrets.GPG_SECRET }}
41+
4042
- name: Set up JDK 11
4143
uses: actions/setup-java@v3
4244
with:
4345
distribution: temurin
4446
java-version: 11
4547
cache: 'maven'
46-
server-id: ossrh
47-
server-username: MAVEN_USERNAME
48-
server-password: MAVEN_PASSWORD
48+
server-id: github
49+
gpg-passphrase: GPG_PASSPHRASE
50+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
4951

50-
- name: Configure Git author
52+
- name: Find version to use
53+
id: version
5154
run: |
52-
git config --local user.email "[email protected]"
53-
git config --local user.name "GitHub Action"
55+
if [[ "${{ github.event.inputs.releaseVersion }}" -eq "auto" ]]; then
56+
echo "No release version provided, using the latest version from the pom.xml"
57+
new_version=`mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout | sed -e 's/-SNAPSHOT$//'`
58+
echo "New version will be $new_version"
59+
echo version=$new_version >> $GITHUB_OUTPUT
60+
else
61+
echo version=${{ github.event.inputs.releaseVersion }} >> $GITHUB_OUTPUT
62+
fi
63+
64+
- name: Pre-Release Check - Version
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
run: |
68+
gh api --method GET /repos/${{github.repository}}/releases -f sort=updated -f direction=asc > releases.json
69+
release_version_exists=$(jq -r --arg RELEASE_VERSION ${{ steps.version.outputs.version }} '.[].name|select(.|test($RELEASE_VERSION))' releases.json)
70+
if [[ ! -z "$release_version_exists" ]]; then
71+
echo "Version ${{ steps.version.outputs.version }} has been previously released. Please change release version."
72+
exit 1
73+
else
74+
echo "New version: ${{ steps.version.outputs.version }} going to be released!"
75+
fi
76+
77+
- name: Release Version - Prepare
78+
run: >-
79+
mvn -B -U versions:set
80+
-DnewVersion=${{ steps.version.outputs.version }}
81+
-DprocessAllModules
82+
-DgenerateBackupPoms=false
83+
5484
5585
- name: Update latest release version in docs
5686
run: |
5787
mvn -B -ntp -pl docs -am generate-resources -Denforcer.skip -Dformatter.skip -Dimpsort.skip
5888
if ! git diff --quiet docs/modules/ROOT/pages/includes/attributes.adoc; then
5989
git add docs/modules/ROOT/pages/includes/attributes.adoc
60-
git commit -m "Update the latest release version ${{steps.metadata.outputs.current-version}} in documentation"
6190
fi
91+
92+
- name: Verify Maven
93+
run: mvn verify
94+
95+
- name: Publishing Test Results - Unit/Integration Tests Pre-Condition
96+
if: always()
97+
id: unit_integration_test_report_exists
98+
uses: andstor/file-existence-action@v2
99+
with:
100+
files: "**/surefire-reports/**/TEST*.xml"
101+
102+
- name: Publishing Test Results - Unit/Integration Tests
103+
uses: dorny/[email protected]
104+
if: always() && steps.unit_integration_test_report_exists.outputs.files_exists == 'true'
105+
with:
106+
name: Test Results
107+
path: "**/surefire-reports/**/TEST*.xml"
108+
fail-on-error: 'false'
109+
reporter: java-junit
110+
only-summary: 'true'
111+
112+
- name: Configure Git author
113+
run: |
114+
git config --local user.email "[email protected]"
115+
git config --local user.name "GitHub Action"
62116
63-
- name: Maven release ${{steps.metadata.outputs.current-version}}
117+
- name: Release Version - Checkin
118+
run: >-
119+
mvn validate
120+
scm:checkin
121+
-DscmVersion=${{ github.event.inputs.sourceBranch }}
122+
-DscmVersionType=branch
123+
-Dmessage="[ci skip] prepare release ${{ steps.version.outputs.version }}" &&
124+
mvn scm:tag -Dtag=${{ steps.version.outputs.version }}
125+
126+
127+
- name: GitHub Packages - Deploy Artifacts
128+
env:
129+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130+
GPG_PASSPHRASE: ${{ secrets.GPG_SECRET }}
64131
run: |
65-
mvn -B release:prepare -Prelease -DreleaseVersion=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}}
66-
mvn -B release:perform -Darguments=-DperformRelease -DperformRelease -Prelease
132+
mvn deploy -Dmaven.install.skip=true -Pgithub,publish
133+
134+
- name: maven-settings-xml-action
135+
uses: whelk-io/maven-settings-xml-action@v4
136+
with:
137+
servers: '[{ "id": "ossrh", "username": "${{ secrets.OSSRH_USER }}", "password": "${{ secrets.OSSRH_PASS }}" }]'
138+
139+
- name: Maven Central - Deploy Artifacts
67140
env:
68-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
69-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
70-
71-
- name: Push changes to ${{github.base_ref}} branch
141+
GPG_PASSPHRASE: ${{ secrets.GPG_SECRET }}
72142
run: |
73-
git push
74-
git push origin ${{steps.metadata.outputs.current-version}}
143+
mvn deploy -Dmaven.install.skip=true -Possrh,publish
144+
145+
- name: Create GitHub Release
146+
uses: ncipollo/release-action@v1
147+
with:
148+
tag: "${{ steps.version.outputs.version }}"
149+
generateReleaseNotes: true
150+
makeLatest: true
151+
152+
- name: Next Develoment Version - Prepare and Checkin
153+
run: >-
154+
mvn -B -U build-helper:parse-version versions:set
155+
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT
156+
-DprocessAllModules
157+
-DgenerateBackupPoms=false &&
158+
mvn validate scm:checkin
159+
-DscmVersion=${{ github.event.inputs.sourceBranch }}
160+
-DscmVersionType=branch
161+
-Dmessage="[ci skip] prepare for next development iteration"
162+
163+

RELEASE.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Solace-Quarkus CD
2+
There is a github actions 'Quarkiverse Release' workflow, which will perform the following actions
3+
- Update and commit POMs to be a release version (eg `1.0.1` vs `1.0.1-SNAPSHOT`)
4+
- Updates the versions within the docs as well
5+
- The version can be explicitly set, or `auto` will use what is currently on the branch, and can be used for easily publishing incremental patch releases.
6+
- Perform a deploy, skipping tests, to both github packages, and ossrh
7+
- Tag, and create a release on github for this commit
8+
- Increment the minor version of all POMs and re-append `-SNAPSHOT`, (eg `1.0.2-SNAPSHOT`)
9+
10+
## Workflows Supported
11+
### Trunk Based (main)
12+
Merge a feature branch to main. This branch should be updated from main and have all tests passing. Once in main, run the release workflow
13+
- Use the `auto` release version if this only requires a patch version bump, otherwise set an appropriate version
14+
15+
### Release branch
16+
In the following depiction of main, trunk based would no longer work if the 1.0 release version need to be maintained with further patch releases
17+
```
18+
[#7fe6b95 Merge Feature branch PR #5] origin/main
19+
[#7a5bde8 [ci skip] prepare for next development iteration ]
20+
[#5ceb311 [ci skip] prepare release 2.0.0] <- Release Quarkiverse action run with releaseVersion=2.0.0
21+
[#5923308 Merge Feature branch PR #4 (Major overhaul)]
22+
[#a46a01a [ci skip] prepare for next development iteration ]
23+
[#e354653 [ci skip] prepare release 1.0.1]
24+
[#3923407 Merge Feature branch PR #3]
25+
[#d76a91b [ci skip] prepare for next development iteration ]
26+
[#f85455c [ci skip] prepare release 1.0.0]
27+
[#7d2115f init]
28+
```
29+
In this case, `git checkout -b release/1.0 a46a01a && git push` This is the sha of the last commit that belongs in this release branch, in this case, the commit setting the version to `1.0.2-SNAPSHOT`
30+
Now the same release workflow can be run, but with `sourceBranch=release/1.0`, and the 2 CI commits will land on the release branch instead of main
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
:project-version: 0
1+
:project-version: ${release.current-version}
22

33
:examples-dir: ./../examples/

docs/pom.xml

+2-19
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<parent>
77
<groupId>com.solace.quarkus</groupId>
88
<artifactId>quarkus-solace-parent</artifactId>
9-
<version>999-SNAPSHOT</version>
9+
<version>0.0.1-SNAPSHOT</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

1313
<artifactId>quarkus-solace-docs</artifactId>
1414
<name>Quarkus Solace - Documentation</name>
15-
15+
<version>0.0.1-SNAPSHOT</version>
1616
<dependencies>
1717
<!-- Make sure the doc is built after the other artifacts -->
1818
<dependency>
@@ -41,23 +41,6 @@
4141
</execution>
4242
</executions>
4343
</plugin>
44-
<plugin>
45-
<groupId>it.ozimov</groupId>
46-
<artifactId>yaml-properties-maven-plugin</artifactId>
47-
<executions>
48-
<execution>
49-
<phase>initialize</phase>
50-
<goals>
51-
<goal>read-project-properties</goal>
52-
</goals>
53-
<configuration>
54-
<files>
55-
<file>${project.basedir}/../.github/project.yml</file>
56-
</files>
57-
</configuration>
58-
</execution>
59-
</executions>
60-
</plugin>
6144
<plugin>
6245
<artifactId>maven-resources-plugin</artifactId>
6346
<executions>

integration-tests/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
<parent>
55
<groupId>com.solace.quarkus</groupId>
66
<artifactId>quarkus-solace-parent</artifactId>
7-
<version>999-SNAPSHOT</version>
7+
<version>0.0.1-SNAPSHOT</version>
88
</parent>
99
<artifactId>quarkus-solace-integration-tests-parent</artifactId>
1010
<name>Quarkus Solace - Integration Tests - Parent</name>
11+
1112
<packaging>pom</packaging>
1213
<modules>
1314
<module>solace-client-integration-tests</module>

integration-tests/solace-client-integration-tests/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.solace.quarkus</groupId>
99
<artifactId>quarkus-solace-integration-tests-parent</artifactId>
10-
<version>999-SNAPSHOT</version>
10+
<version>0.0.1-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>solace-client-integration-tests</artifactId>

0 commit comments

Comments
 (0)