[[ReleaseGuide-ReleaseGuide]]
= Apache Camel Quarkus release process
:page-aliases: release-guide.adoc

The process is _mutatis mutandis_ the same as for the main Apache Camel repository - see the
xref:latest@manual::release-guide.adoc[Release guide] page of the Camel documentation.

Here, just a sketch of the repeating part, after you have performed the initial setup following the
xref:latest@manual::release-guide.adoc[Camel Release guide].

== Pre release tasks

* When releasing after a recent Quarkus release, check for new releases of third party Quarkus extensions we depend on.
  They are listed in the https://github.com/apache/camel-quarkus/blob/main/pom.xml#L46-L54[Primary dependencies] section of the top level `pom.xml`.
  If there are new releases, upgrade the versions accordingly and run `mvn cq:sync-versions -N` from the root directory of the source tree.
* Close the GitHub release https://github.com/apache/camel-quarkus/milestones[milestone] and assign any remaining issues that aren't covered by the release to the next milestone

== Create a release branch

[source,shell]
----
$ export VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's|-SNAPSHOT||') # the version you are releasing, e.g. 0.1.0
$ export NEXT_VERSION=$(echo ${VERSION} | awk -F. -v OFS=. '{$NF++;print}')-SNAPSHOT # the next development iteration, e.g. 0.1.1-SNAPSHOT
$ export BRANCH=$(echo $VERSION | sed 's|.[0-9][0-9]*$|.x|') # the release branch, e.g. 0.1.x
$ git fetch upstream # upstream is git@github.com:apache/camel-quarkus.git
$ git checkout main # main is the branch from which you want to release
$ git reset --hard upstream/main # make sure you are in sync with upstream
$ git checkout -b $BRANCH
----

== `release:prepare` and `release:perform`

With Camel Quarkus, adding `-Prelease` to `release:prepare` and `release:perform` is not necessary,
because all necessary profiles are set in the configuration of the `maven-release-plugin`.

The Maven command to release is as follows:

[source,shell]
----
$ mvn clean release:clean release:prepare -DreleaseVersion=$VERSION -DdevelopmentVersion=$NEXT_VERSION -B release:perform
----

In case `release:prepare` is successful but an issue occurs during `release:perform`, you can resume from the failing artifact to save some time:
* First find out from the console output, in which module the `release:perform` task failed.
  Say that there was an upload timeout in `camel-quarkus-openapi-java` module.
* Then locate the directory `mvn release:perform` used for checking out the tag and running the `deploy` goal.
  It is usually `<root_of_the_project>/target/checkout`:
+
[source,shell]
----
$ cd target/checkout
----
+
* And finally resume the `deploy` build as follows:
+
[source,shell]
----
$ mvn deploy -Papache-release -DskipTests -Denforcer.skip -Dquarkus.build.skip -Dformatter.skip -Dimpsort.skip -Dskip.installyarn -Dskip.yarn -rf :camel-quarkus-openapi-java
----

== Next version in Camel Quarkus main branch

If there are no substantial commits in the release branch, which need to get merged/cherry-picked to `main`, you can
perform this step right after creating the release branch. Otherwise, e.g. if there is a Camel upgrade in the release
branch which is not available on Maven Central yet, it is better to perform this step after the new Camel release is
available on the Central and after all relevant commits were merged/cherry-picked to `main`.

While in the release branch we set the `$NEXT_VERSION` to the next micro SNAPSHOT (e.g. when releasing `0.1.0`,
`$NEXT_VERSION` would be `0.1.1-SNAPSHOT`), in `main`, we typically set the next version to the next minor
SNAPSHOT (the next minor SNAPSHOT of `0.1.0` is `0.2.0-SNAPSHOT`).

[source,shell]
----
$ NEXT_RELEASE=... # e.g. 0.2.0
$ NEXT_SNAPSHOT="${NEXT_RELEASE}-SNAPSHOT"
$ git checkout "main"
$ git reset upstream/main
$ mvn release:update-versions -DautoVersionSubmodules=true -DdevelopmentVersion=$NEXT_SNAPSHOT -B
$ sed -i "s|<camel.quarkus.jvmSince>[^<]*</camel.quarkus.jvmSince>|<camel.quarkus.jvmSince>$NEXT_RELEASE</camel.quarkus.jvmSince>|" tooling/create-extension-templates/runtime-pom.xml
$ sed -i "s|<camel.quarkus.nativeSince>[^<]*</camel.quarkus.nativeSince>|<camel.quarkus.nativeSince>$NEXT_RELEASE</camel.quarkus.nativeSince>|" tooling/create-extension-templates/runtime-pom.xml
$ (cd extensions/qute && mvn clean install -Dquickly) # to regen the Qute Camel component metadata
$ git add -A
$ git commit -m "Next is $NEXT_RELEASE"
# Send a pull request
----

== Update the Apache Camel Quarkus distribution subversion repository

Once the staging repository has been released, the Apache Camel Quarkus distribution subversion repository should be updated as sketched below.

If you are doing this for the first time you need to checkout the Apache Camel Quarkus distribution subversion repository:
[source,shell]
----
$ svn checkout 'https://dist.apache.org/repos/dist/release/camel' camel-releases-dist
----

In case you have performed the above step during some release in the past, you need to update your working copy:

[source,shell]
----
$ cd camel-releases-dist
$ svn update .
----

Make sure your public key is present in the `KEYS` file. Add it, if it is not there yet using `gpg` command:

[source,shell]
----
$ export EMAIL= # the e-mail address in your key
$ gpg -k $EMAIL >> KEYS
$ gpg --armor --export $EMAIL >> KEYS
----

Assemble the Apache Camel Quarkus distribution:
[source,shell]
----
$ mkdir -p "camel-quarkus/$VERSION"
$ cd "camel-quarkus/$VERSION"
$ export URL='https://repository.apache.org/content/repositories/releases/org/apache/camel/quarkus/camel-quarkus'
$ wget -O "apache-camel-quarkus-$VERSION-src.zip" "$URL/$VERSION/camel-quarkus-$VERSION-src.zip"
$ wget -O "apache-camel-quarkus-$VERSION-src.zip.asc" "$URL/$VERSION/camel-quarkus-$VERSION-src.zip.asc"
$ sha512sum "apache-camel-quarkus-$VERSION-src.zip" > "apache-camel-quarkus-$VERSION-src.zip.sha512"
----
Ensure that only the latest release from each maintained branches is present.
Typically, when releasing e.g. 1.4.0, you may need to delete e.g. 1.3.0:

[source,shell]
----
$ cd .. && ls
$ rm -fr 1.3.0
----
Review the changes:
[source,shell]
----
$ svn diff
----
Commit the changes:
[source,shell]
----
$ cd camel-releases-dist
$ svn add --force .
$ svn commit -m "Apache Camel Quarkus $VERSION released artifacts"
----

== Create a GitHub release

This will trigger sending a notification to folks watching the Camel Quarkus github repository,
so it should ideally happen once the newly released artifacts are available on https://repo1.maven.org/maven2/org/apache/camel/quarkus/camel-quarkus-bom/[Maven Central].

The following needs to be done:

* Go to https://github.com/apache/camel-quarkus/releases[https://github.com/apache/camel-quarkus/releases].
* Click the tag you want to promote to a GitHub release
* Click "Edit Tag" button
* In the "New release" form:
  * Leave "Release title" empty
  * Add something meaningful to the description, e.g. something like
+
[source,markdown]
----
Check the full [release announcement](https://camel.apache.org/blog/2021/06/camel-quarkus-release-2.0.0/)
----
+
  * Click the green "Publish release" button at the bottom

== Upgrade Camel Quarkus in Quarkus Platform

When: once the newly released artifacts are available on https://repo1.maven.org/maven2/org/apache/camel/quarkus/camel-quarkus-bom/[Maven Central].

[INFO]
====
https://github.com/quarkusio/quarkus-platform[Quarkus Platform] hosts the metadata and Maven BOMs necessary for
https://code.quarkus.io/[code.quarkus.io] as well as for https://quarkus.io/guides/tooling[Quarkus tools].
====

* Clone Quarkus Platform unless you have done it in the past
+
[source,shell]
----
$ git clone git@github.com:quarkusio/quarkus-platform.git
----
+
* Change `camel-quarkus.version` property in the Quarkus platform top level `https://github.com/quarkusio/quarkus-platform/blob/main/pom.xml#L54[pom.xml]` to the newly released version:
+
[source,shell]
----
$ cd quarkus-platform
$ export NEW_VERSION=... # the version you just released, e.g. 0.1.0
$ sed -i "s|<camel-quarkus.version>[^<]*</camel-quarkus.version>|<camel-quarkus.version>$NEW_VERSION</camel-quarkus.version>|" pom.xml
# Make sure that it worked
$ git status
----
+
* Re-generate the BOMs
+
[source,shell]
----
$ mvn clean install -DskipTests
# ^ This will take a couple of minutes because it resolves
# every single dependency of every single extension included
# in the platform

# Then commit the generated changes
$ git add -A
$ git commit -m "Upgrade to Camel Quarkus $NEW_VERSION"
----
+
* Run Camel Quarkus integration tests at least in JVM mode:
+
[source,shell]
----
cd generated-platform-project/quarkus-camel/integration-tests
mvn clean test
----
+
* If all tests are passing, send a pull request to the Platform

== Further steps

In addition to the above, the following is needed:

* Check the state of `camel-quarkus-main` branch in the
  https://github.com/apache/camel-quarkus-examples[Examples repository]. If the version properties are in sync with
  new Camel Quarkus release and if the tests are passing, merge `camel-quarkus-main` to `main`.
* https://github.com/apache/camel-quarkus/issues/new[Create a ticket] asking a https://projects.apache.org/committee.html?camel[PMC member] to update the https://reporter.apache.org/addrelease.html?camel[Apache Committee Report Helper]. The ticket title could be as follow.
  Release: The Apache Committee Report Helper should be updated by a PMC member as camel-quarkus-X.Y.Z has been released on YYYY-MM-DD.
* When writing the release announcement blog post, do not forget to add the release note section in https://github.com/apache/camel-website/tree/main/content/releases/q
