From c61f87f4d53f5707f5881c507883ffe3cbc99d6a Mon Sep 17 00:00:00 2001 From: Francesco Guardiani Date: Tue, 1 Sep 2020 11:35:53 +0200 Subject: [PATCH] Release automation (#191) Signed-off-by: Francesco Guardiani --- core/README.md | 10 ++++ docs/index.md | 2 +- scripts/release.md | 24 ++++++++++ scripts/trigger_release.sh | 94 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 scripts/release.md create mode 100755 scripts/trigger_release.sh diff --git a/core/README.md b/core/README.md index 5b21e9a8..40a39a52 100644 --- a/core/README.md +++ b/core/README.md @@ -6,6 +6,16 @@ The base classes, interfaces and low-level APIs to use CloudEvents. ## How to Use +For Maven based projects, use the following dependency: + +```xml + + io.cloudevents + cloudevents-api + 2.0.0-milestone1 + +``` + ### Create an Event ```java diff --git a/docs/index.md b/docs/index.md index 40186967..b8117aa7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -43,7 +43,7 @@ The CloudEvents SDK for Java is composed by several modules, each one providing * [`cloudevents-http-restful-ws`] Implementation of [HTTP Protocol Binding] for [Jakarta Restful WS](https://jakarta.ee/specifications/restful-ws/) * [`cloudevents-kafka`] Implementation of [Kafka Protocol Binding] -The latest SDK version is _2.0.0-milestone1_. +You can look at the latest published artifacts on [Maven Central](https://search.maven.org/search?q=g:io.cloudevents). ## Get Started diff --git a/scripts/release.md b/scripts/release.md new file mode 100644 index 00000000..25ef64bf --- /dev/null +++ b/scripts/release.md @@ -0,0 +1,24 @@ +# Release process + +The release is automatically performed by Travis CI. + +In order to trigger it, you can use the script `trigger_release.sh` like: + +```bash +./scripts/trigger_release.sh --release 2.0.0-milestone2 --snapshot 2.1.0-SNAPSHOT --upstream origin +``` + +This script will: + +- Perform a dump of the release using the release version +- Update all the \*.md containing the release version +- Tag and commit all the above changes and eventually push them to the + provided remote +- Perform a dump of the version back to the provided snapshot version +- Commit all the above changes and eventually push them to the provided remote + +After the script performed all the changes, you can create the new release on +GitHub: https://github.com/cloudevents/sdk-java/releases/new + +Note: Before running it pointing to upstream/master, try always in your local +repo diff --git a/scripts/trigger_release.sh b/scripts/trigger_release.sh new file mode 100755 index 00000000..72ffbc82 --- /dev/null +++ b/scripts/trigger_release.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +function die() { echo "$*" 1>&2 ; exit 1; } + +# Example usage +# ./scripts/trigger_release.sh --upstream upstream --release 2.0.0 --snapshot 2.1.0-SNAPSHOT + +# In order to start the release the script: +# * Performs a dump of the release using the release version +# * Updates all the *.md containing the release version +# * Commits all the above changes and eventually push them to the provided remote +# * Performs a dump of the version back to the provided snapshot version +# * Commits all the above changes and eventually push them to the provided remote + +THIS_BRANCH=$(git rev-parse --abbrev-ref HEAD) +REMOTE="" +NEW_SNAPSHOT="" +NEW_VERSION="" + +# Loop through arguments and process them +while (( "$#" )); do + case $1 in + -u|--upstream) + if [[ -n $2 ]]; then + REMOTE=$2 + shift + else + die 'ERROR: "--upstream" requires a non-empty option argument.' + fi + ;; + -r|--release) + if [[ -n $2 ]]; then + NEW_VERSION=$2 + shift + else + die 'ERROR: "--version" requires a non-empty option argument.' + fi + ;; + -s|--snapshot) + if [[ -n $2 ]]; then + NEW_SNAPSHOT=$2 + shift + else + die 'ERROR: "--snapshot" requires a non-empty option argument.' + fi + ;; + esac + shift +done + +if [ -z "$REMOTE" ]; then + echo "Remote is not specified, I'm gonna perform the changes only locally" +else + echo "Going to release on remote $REMOTE" +fi + +if [ -z "$NEW_VERSION" ]; then + die 'ERROR: version is not specified' +fi + +if [ -z "$NEW_SNAPSHOT" ]; then + die 'ERROR: new snapshot is not specified' +fi + +echo "Dumping to release $NEW_VERSION" + +mvn versions:set -DnewVersion="$NEW_VERSION" +find . -name "pom.xml" -exec git add {} \; +sed -i -e "s+[a-zA-Z0-9.-]*<\/version>+$NEW_VERSION+g" ***/*.md +find . -name "*.md" -exec git add {} \; + +git commit --signoff -m "Release $NEW_VERSION" +git tag $NEW_VERSION + +if [ -n "$REMOTE" ]; then + git push --follow-tags -u $REMOTE $THIS_BRANCH +fi + +echo "Dumping to snapshot $NEW_SNAPSHOT" + +mvn versions:set -DnewVersion="$NEW_SNAPSHOT" +find . -name "pom.xml" -exec git add {} \; + +git commit --signoff -m "Release $NEW_SNAPSHOT" + +if [ -n "$REMOTE" ]; then + git push -u $REMOTE $THIS_BRANCH +fi + +echo "Done! Now you can create the release on GitHub!"