Skip to content

Commit

Permalink
DATAGO-70348: Publish quarkus to Maven Central (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkbains authored Feb 12, 2024
2 parents 2707c64 + 099002f commit c3dc2da
Show file tree
Hide file tree
Showing 17 changed files with 295 additions and 113 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- "main"
- 'release/*'
paths-ignore:
- '.gitignore'
- 'CODEOWNERS'
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/pre-release.yml

This file was deleted.

159 changes: 124 additions & 35 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,74 +1,163 @@
name: Quarkiverse Release

on:
pull_request:
types: [closed]
paths:
- '.github/project.yml'
workflow_dispatch:
inputs:
releaseVersion:
description: "Version to use when preparing a release. Use `auto` to use the latest version from the pom.xml."
required: true
default: "auto"
sourceBranch:
description: "Which branch contains the previous release version."
default: "main"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
group: "quarkiverse-release"
cancel-in-progress: false

defaults:
run:
shell: bash
permissions:
contents: write
packages: write
checks: write


jobs:
release:
runs-on: ubuntu-latest
name: release
if: ${{github.event.pull_request.merged == true}}

steps:
- uses: radcortez/project-metadata-action@main
name: Retrieve project metadata
id: metadata
- uses: actions/checkout@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
metadata-file-path: '.github/project.yml'

- uses: actions/checkout@v3
ref: ${{ github.event.inputs.sourceBranch }}

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 #v6.1.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

passphrase: ${{ secrets.GPG_SECRET }}
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
server-id: github
gpg-passphrase: GPG_PASSPHRASE
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}

- name: Configure Git author
- name: Find version to use
id: version
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
if [[ "${{ github.event.inputs.releaseVersion }}" -eq "auto" ]]; then
echo "No release version provided, using the latest version from the pom.xml"
new_version=`mvn -B help:evaluate -Dexpression=project.version -q -DforceStdout | sed -e 's/-SNAPSHOT$//'`
echo "New version will be $new_version"
echo version=$new_version >> $GITHUB_OUTPUT
else
echo version=${{ github.event.inputs.releaseVersion }} >> $GITHUB_OUTPUT
fi
- name: Pre-Release Check - Version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api --method GET /repos/${{github.repository}}/releases -f sort=updated -f direction=asc > releases.json
release_version_exists=$(jq -r --arg RELEASE_VERSION ${{ steps.version.outputs.version }} '.[].name|select(.|test($RELEASE_VERSION))' releases.json)
if [[ ! -z "$release_version_exists" ]]; then
echo "Version ${{ steps.version.outputs.version }} has been previously released. Please change release version."
exit 1
else
echo "New version: ${{ steps.version.outputs.version }} going to be released!"
fi
- name: Release Version - Prepare
run: >-
mvn -B -U versions:set
-DnewVersion=${{ steps.version.outputs.version }}
-DprocessAllModules
-DgenerateBackupPoms=false
- name: Update latest release version in docs
run: |
mvn -B -ntp -pl docs -am generate-resources -Denforcer.skip -Dformatter.skip -Dimpsort.skip
if ! git diff --quiet docs/modules/ROOT/pages/includes/attributes.adoc; then
git add docs/modules/ROOT/pages/includes/attributes.adoc
git commit -m "Update the latest release version ${{steps.metadata.outputs.current-version}} in documentation"
fi
- name: Verify Maven
run: mvn verify

- name: Publishing Test Results - Unit/Integration Tests Pre-Condition
if: always()
id: unit_integration_test_report_exists
uses: andstor/file-existence-action@v2
with:
files: "**/surefire-reports/**/TEST*.xml"

- name: Publishing Test Results - Unit/Integration Tests
uses: dorny/[email protected]
if: always() && steps.unit_integration_test_report_exists.outputs.files_exists == 'true'
with:
name: Test Results
path: "**/surefire-reports/**/TEST*.xml"
fail-on-error: 'false'
reporter: java-junit
only-summary: 'true'

- name: Configure Git author
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Maven release ${{steps.metadata.outputs.current-version}}
- name: Release Version - Checkin
run: >-
mvn validate
scm:checkin
-DscmVersion=${{ github.event.inputs.sourceBranch }}
-DscmVersionType=branch
-Dmessage="[ci skip] prepare release ${{ steps.version.outputs.version }}" &&
mvn scm:tag -Dtag=${{ steps.version.outputs.version }}
- name: GitHub Packages - Deploy Artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_SECRET }}
run: |
mvn -B release:prepare -Prelease -DreleaseVersion=${{steps.metadata.outputs.current-version}} -DdevelopmentVersion=${{steps.metadata.outputs.next-version}}
mvn -B release:perform -Darguments=-DperformRelease -DperformRelease -Prelease
mvn deploy -Dmaven.install.skip=true -Pgithub,publish
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v4
with:
servers: '[{ "id": "ossrh", "username": "${{ secrets.OSSRH_USER }}", "password": "${{ secrets.OSSRH_PASS }}" }]'

- name: Maven Central - Deploy Artifacts
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}

- name: Push changes to ${{github.base_ref}} branch
GPG_PASSPHRASE: ${{ secrets.GPG_SECRET }}
run: |
git push
git push origin ${{steps.metadata.outputs.current-version}}
mvn deploy -Dmaven.install.skip=true -Possrh,publish
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: "${{ steps.version.outputs.version }}"
generateReleaseNotes: true
makeLatest: true

- name: Next Develoment Version - Prepare and Checkin
run: >-
mvn -B -U build-helper:parse-version versions:set
-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT
-DprocessAllModules
-DgenerateBackupPoms=false &&
mvn validate scm:checkin
-DscmVersion=${{ github.event.inputs.sourceBranch }}
-DscmVersionType=branch
-Dmessage="[ci skip] prepare for next development iteration"
30 changes: 30 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Solace-Quarkus CD
There is a github actions 'Quarkiverse Release' workflow, which will perform the following actions
- Update and commit POMs to be a release version (eg `1.0.1` vs `1.0.1-SNAPSHOT`)
- Updates the versions within the docs as well
- 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.
- Perform a deploy, skipping tests, to both github packages, and ossrh
- Tag, and create a release on github for this commit
- Increment the minor version of all POMs and re-append `-SNAPSHOT`, (eg `1.0.2-SNAPSHOT`)

## Workflows Supported
### Trunk Based (main)
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
- Use the `auto` release version if this only requires a patch version bump, otherwise set an appropriate version

### Release branch
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
```
[#7fe6b95 Merge Feature branch PR #5] origin/main
[#7a5bde8 [ci skip] prepare for next development iteration ]
[#5ceb311 [ci skip] prepare release 2.0.0] <- Release Quarkiverse action run with releaseVersion=2.0.0
[#5923308 Merge Feature branch PR #4 (Major overhaul)]
[#a46a01a [ci skip] prepare for next development iteration ]
[#e354653 [ci skip] prepare release 1.0.1]
[#3923407 Merge Feature branch PR #3]
[#d76a91b [ci skip] prepare for next development iteration ]
[#f85455c [ci skip] prepare release 1.0.0]
[#7d2115f init]
```
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`
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
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/includes/attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:project-version: 0
:project-version: ${release.current-version}

:examples-dir: ./../examples/
21 changes: 2 additions & 19 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<parent>
<groupId>com.solace.quarkus</groupId>
<artifactId>quarkus-solace-parent</artifactId>
<version>999-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>quarkus-solace-docs</artifactId>
<name>Quarkus Solace - Documentation</name>

<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- Make sure the doc is built after the other artifacts -->
<dependency>
Expand Down Expand Up @@ -41,23 +41,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>it.ozimov</groupId>
<artifactId>yaml-properties-maven-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${project.basedir}/../.github/project.yml</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
<parent>
<groupId>com.solace.quarkus</groupId>
<artifactId>quarkus-solace-parent</artifactId>
<version>999-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>quarkus-solace-integration-tests-parent</artifactId>
<name>Quarkus Solace - Integration Tests - Parent</name>

<packaging>pom</packaging>
<modules>
<module>solace-client-integration-tests</module>
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/solace-client-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.solace.quarkus</groupId>
<artifactId>quarkus-solace-integration-tests-parent</artifactId>
<version>999-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>solace-client-integration-tests</artifactId>
Expand Down
Loading

0 comments on commit c3dc2da

Please sign in to comment.