diff --git a/.circleci/config.yml b/.circleci/config.yml index 0877047dc..a558d00cc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,15 +28,23 @@ jobs: fingerprints: - "cd:a8:80:f3:5e:9a:37:30:ef:55:20:b5:1f:b9:e5:18" - deploy: - command: | # Deploy if on main branch. If the $RELEASE and $NEXT variables are set then prepare a full maven release. - if [ "${CIRCLE_BRANCH}" == "main" ]; then + command: | # Deploy from the main branch or from a version branch/tag. If the $RELEASE and $NEXT variables are set then prepare a full maven release. + if [[ "${CIRCLE_BRANCH}" =~ v[0-9]+\.[0-9]+\.[0-9]+ ]]; then + RELEASE="${CIRCLE_BRANCH}" + NEXT="${CIRCLE_BRANCH}-SNAPSHOT" + DO_RELEASE=1 + fi + if [[ "${CIRCLE_BRANCH}" == "main" || -n "${DO_RELEASE}" ]]; then echo $GPG_KEY | base64 --decode > signing-key gpg --passphrase $GPG_PASSPHRASE --import signing-key shred signing-key if [[ -n "${RELEASE}" && -n "${NEXT}" ]]; then git config --global user.email "envoy-bot@users.noreply.github.com" git config --global user.name "envoy-bot" - mvn -B -s ../.circleci/settings.xml release:prepare release:perform -Darguments="-s ../.circleci/settings.xml" -DreleaseVersion=$RELEASE -DdevelopmentVersion=$NEXT -DscmCommentPrefix="java release: " + mvn -B -s ../.circleci/settings.xml release:prepare release:perform \ + -Darguments="-s ../.circleci/settings.xml" \ + -DreleaseVersion=$RELEASE -DdevelopmentVersion=$NEXT \ + -DscmCommentPrefix="java release: " else mvn -B -s ../.circleci/settings.xml deploy fi diff --git a/java/RELEASING.md b/java/RELEASING.md index d7cd238de..f06bafdec 100644 --- a/java/RELEASING.md +++ b/java/RELEASING.md @@ -5,9 +5,9 @@ These steps are for releasing the Java components of PGV: - pgv-java-grpc - pgv-artifacts -## Releasing from master using CI +## Releasing using CI -Releasing from master is fully automated by CI, but can't release historic tags. +Releasing from main is fully automated by CI: ``` curl -X POST -H "Content-Type: application/json" -d '{ "build_parameters": { @@ -16,9 +16,24 @@ curl -X POST -H "Content-Type: application/json" -d '{ "NEXT": "-SNAPSHOT", "GIT_USER_EMAIL": "envoy-bot@users.noreply.github.com", "GIT_USER_NAME": "Via CircleCI" -}}' "https://circleci.com/api/v1.1/project/github/envoyproxy/protoc-gen-validate/tree/master?circle-token=" +}}' "https://circleci.com/api/v1.1/project/github/envoyproxy/protoc-gen-validate/tree/main?circle-token=" ``` +Releasing from versioned tags is similar. To release version `vX.Y.Z`, first +create a Git tag called `vX.Y.Z` (preferably through the GitHub release flow), +then run the following to kick off a release build: +``` +curl -X POST -H "Content-Type: application/json" -d '{ +"build_parameters": { + "CIRCLE_JOB": "javabuild", + "GIT_USER_EMAIL": "envoy-bot@users.noreply.github.com", + "GIT_USER_NAME": "Via CircleCI" +}}' "https://circleci.com/api/v1.1/project/github/envoyproxy/protoc-gen-validate/tree/v.X.Y.Z?circle-token=" +``` + +The `javabuild` CI flow will use the version number from the tag to deploy to +the Maven repository. + ## Manually releasing from git history Manually releasing from git history is a more involved process, but allows you @@ -34,4 +49,4 @@ to release from any point in the history. ``` mvn -B -s /path/to/settings.xml clean release:prepare release:perform -Darguments="-s /path/to/settings.xml" -DreleaseVersion=x.y.z -DdevelopmentVersion=x.y.z-SNAPSHOT -DscmCommentPrefix="java release: " -``` \ No newline at end of file +```