|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -e |
| 3 | + |
| 4 | +# Make sure, everything is English... |
| 5 | +export LANG=en_US.UTF-8 |
| 6 | + |
| 7 | +# verify the current directory |
| 8 | +PMD_GITHUB_IO_DIR="../pmd.github.io" |
| 9 | +if [ ! -f pom.xml ] || [ ! -d ${PMD_GITHUB_IO_DIR} ]; then |
| 10 | + echo "You seem to be in the wrong working directory or you don't have pmd.github.io checked out..." |
| 11 | + echo |
| 12 | + echo "Expected:" |
| 13 | + echo "* You are currently in the pmd-eclipse-plugin repository" |
| 14 | + echo "* ${PMD_GITHUB_IO_DIR} is the pmd.github.io repository" |
| 15 | + echo |
| 16 | + exit 1 |
| 17 | +fi |
| 18 | + |
| 19 | +RELEASE_VERSION= |
| 20 | +DEVELOPMENT_VERSION= |
| 21 | +CURRENT_BRANCH= |
| 22 | + |
| 23 | +echo "-------------------------------------------" |
| 24 | +echo "Releasing PMD Eclipse Plugin" |
| 25 | +echo "-------------------------------------------" |
| 26 | + |
| 27 | +CURRENT_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout) |
| 28 | +RELEASE_VERSION=${CURRENT_VERSION%-SNAPSHOT} |
| 29 | +MAJOR=$(echo "$RELEASE_VERSION" | cut -d . -f 1) |
| 30 | +MINOR=$(echo "$RELEASE_VERSION" | cut -d . -f 2) |
| 31 | +PATCH=$(echo "$RELEASE_VERSION" | cut -d . -f 3) |
| 32 | +if [ "$PATCH" == "0" ]; then |
| 33 | + NEXT_MINOR=$(("${MINOR}" + 1)) |
| 34 | + NEXT_PATCH="0" |
| 35 | +else |
| 36 | + # this is a bugfixing release |
| 37 | + NEXT_MINOR="${MINOR}" |
| 38 | + NEXT_PATCH=$(("${PATCH}" + 1)) |
| 39 | +fi |
| 40 | +DEVELOPMENT_VERSION="$MAJOR.$NEXT_MINOR.$NEXT_PATCH" |
| 41 | +DEVELOPMENT_VERSION="${DEVELOPMENT_VERSION}" |
| 42 | + |
| 43 | +# allow to override the next version, e.g. via "NEXT_VERSION=7.0.0 ./do-release.sh" |
| 44 | +if [ "$NEXT_VERSION" != "" ]; then |
| 45 | + DEVELOPMENT_VERSION="${NEXT_VERSION}" |
| 46 | +fi |
| 47 | + |
| 48 | +# http://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch |
| 49 | +CURRENT_BRANCH=$(git symbolic-ref -q HEAD) |
| 50 | +CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} |
| 51 | +CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} |
| 52 | + |
| 53 | +# Pick a release BUILDQUALIFIER (e.g. v20170401-0001) and update versions |
| 54 | +# E.g. version is: "4.0.13" and BUILDQUALIFIER is "v20170401-0001". |
| 55 | +# The complete version of the plugin will be "4.0.13.v20170401-0001 |
| 56 | +BUILDQUALIFIER=$(date -u +v%Y%m%d-%H%M) |
| 57 | +export BUILDQUALIFIER |
| 58 | + |
| 59 | +echo "RELEASE_VERSION: ${RELEASE_VERSION}.${BUILDQUALIFIER} (this release)" |
| 60 | +echo "DEVELOPMENT_VERSION: ${DEVELOPMENT_VERSION} (the next version after the release)" |
| 61 | +echo "CURRENT_BRANCH: ${CURRENT_BRANCH}" |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +echo Update the ReleaseNotes with the release date and version: |
| 66 | +echo |
| 67 | +echo "## $(date -u +%d-%B-%Y): ${RELEASE_VERSION}.${BUILDQUALIFIER}" |
| 68 | +echo |
| 69 | +echo "And also remove any empty/unnecessary sections" |
| 70 | +echo |
| 71 | +echo "Press enter to continue..." |
| 72 | +read -r |
| 73 | +./mvnw org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion="${RELEASE_VERSION}.${BUILDQUALIFIER}" -Dtycho.mode=maven |
| 74 | +git commit -a -m "Prepare release pmd-eclipse-plugin ${RELEASE_VERSION}.${BUILDQUALIFIER}" |
| 75 | +git tag "${RELEASE_VERSION}.${BUILDQUALIFIER}" |
| 76 | +echo "Create (temporary) release branch" |
| 77 | +git branch "pmd-eclipse-plugin-rb-${RELEASE_VERSION}" |
| 78 | + |
| 79 | +echo |
| 80 | +echo Updating the ReleaseNotes and add a next version entry... |
| 81 | +BEGIN_LINE=$(grep -n "^## " ReleaseNotes.md|head -1|cut -d ":" -f 1) |
| 82 | +BEGIN_LINE=$((BEGIN_LINE - 1)) |
| 83 | +RELEASE_NOTES_HEADER=$(head -$BEGIN_LINE ReleaseNotes.md) |
| 84 | +RELEASE_NOTES_BODY=$(tail --lines=+$BEGIN_LINE ReleaseNotes.md) |
| 85 | + |
| 86 | +cat <<EOF > ReleaseNotes.md |
| 87 | +${RELEASE_NOTES_HEADER} |
| 88 | +
|
| 89 | +## ????: ${DEVELOPMENT_VERSION}.v???? |
| 90 | +
|
| 91 | +This is a minor release. |
| 92 | +
|
| 93 | +### New and noteworthy |
| 94 | +
|
| 95 | +### Fixed Issues |
| 96 | +
|
| 97 | +### API Changes |
| 98 | +
|
| 99 | +### External Contributions |
| 100 | +${RELEASE_NOTES_BODY} |
| 101 | +
|
| 102 | +EOF |
| 103 | + |
| 104 | +echo |
| 105 | +echo "Updating version in master to next" |
| 106 | +./mvnw org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion="${DEVELOPMENT_VERSION}-SNAPSHOT" -Dtycho.mode=maven |
| 107 | +git commit -a -m "Prepare next pmd-eclipse-plugin development version ${DEVELOPMENT_VERSION}-SNAPSHOT" |
| 108 | +echo "Pushing master" |
| 109 | +git push origin master |
| 110 | + |
| 111 | +echo |
| 112 | +echo Checkout the release branch and build the plugin |
| 113 | +git checkout "pmd-eclipse-plugin-rb-${RELEASE_VERSION}" |
| 114 | + |
| 115 | +./mvnw clean verify |
| 116 | + |
| 117 | +# extract the release notes |
| 118 | +BEGIN_LINE=$(grep -n "^## " ReleaseNotes.md|head -1|cut -d ":" -f 1) |
| 119 | +END_LINE=$(grep -n "^## " ReleaseNotes.md|head -2|tail -1|cut -d ":" -f 1) |
| 120 | +END_LINE=$((END_LINE - 1)) |
| 121 | + |
| 122 | +RELEASE_BODY="A new PMD for Eclipse plugin version has been released. |
| 123 | +It is available via the update site: https://pmd.github.io/pmd-eclipse-plugin-p2-site/ |
| 124 | +
|
| 125 | +$(head -$END_LINE ReleaseNotes.md|tail -$((END_LINE - BEGIN_LINE))) |
| 126 | +" |
| 127 | + |
| 128 | + |
| 129 | +echo |
| 130 | +echo "Please test now!!!" |
| 131 | +echo |
| 132 | +echo "Update-site: jar:file:$(pwd)/net.sourceforge.pmd.eclipse.p2updatesite/target/net.sourceforge.pmd.eclipse.p2updatesite-${RELEASE_VERSION}.${BUILDQUALIFIER}.zip!/" |
| 133 | +echo |
| 134 | +read -r |
| 135 | + |
| 136 | +echo |
| 137 | +echo "Publishing now..." |
| 138 | +git restore net.sourceforge.pmd.eclipse.p2updatesite/category.xml |
| 139 | +git checkout master |
| 140 | +git branch -D "pmd-eclipse-plugin-rb-${RELEASE_VERSION}" |
| 141 | +git push origin tag "${RELEASE_VERSION}.${BUILDQUALIFIER}" |
| 142 | +echo |
| 143 | +echo |
| 144 | + |
| 145 | +echo |
| 146 | +echo Wait for github build to finish: https://github.com/pmd/pmd-eclipse-plugin/actions |
| 147 | +echo |
| 148 | +echo Verify, zipped update site has been uploaded to |
| 149 | +echo " * https://github.com/pmd/pmd-eclipse-plugin/releases" |
| 150 | +echo " * https://pmd.github.io/pmd-eclipse-plugin-p2-site/" |
| 151 | +echo " * https://sourceforge.net/projects/pmd/files/pmd-eclipse/zipped/" |
| 152 | +echo "Verify, news entry has been created: https://sourceforge.net/p/pmd/news/" |
| 153 | +echo |
| 154 | +echo Update the marketplace entry with the new version: |
| 155 | +echo https://marketplace.eclipse.org/content/pmd-eclipse-plugin/edit |
| 156 | +echo |
| 157 | + |
| 158 | +echo |
| 159 | +tweet="PMD for Eclipse ${RELEASE_VERSION}.${BUILDQUALIFIER} released #PMD |
| 160 | +Update site: https://pmd.github.io/pmd-eclipse-plugin-p2-site/ |
| 161 | +Release notes: https://github.com/pmd/pmd-eclipse-plugin/blob/${RELEASE_VERSION}.${BUILDQUALIFIER}/ReleaseNotes.md" |
| 162 | +tweet="${tweet// /%20}" |
| 163 | +tweet="${tweet//:/%3A}" |
| 164 | +tweet="${tweet//#/%23}" |
| 165 | +tweet="${tweet//\//%2F}" |
| 166 | +tweet="${tweet//$'\r'/}" |
| 167 | +tweet="${tweet//$'\n'/%0A}" |
| 168 | +echo "Tweet about this release on https://twitter.com/pmd_analyzer:" |
| 169 | +echo " <https://twitter.com/intent/tweet?text=$tweet>" |
| 170 | +echo |
| 171 | + |
| 172 | +POST_FILE="_posts/$(date +%Y-%m-%d)-PMD-for-Eclipse-${RELEASE_VERSION}.${BUILDQUALIFIER}-released.md" |
| 173 | +cat > "${PMD_GITHUB_IO_DIR}/${POST_FILE}" <<EOF |
| 174 | +--- |
| 175 | +layout: post |
| 176 | +title: PMD For Eclipse ${RELEASE_VERSION}.${BUILDQUALIFIER} Released |
| 177 | +--- |
| 178 | +
|
| 179 | +${RELEASE_BODY} |
| 180 | +EOF |
| 181 | + |
| 182 | +pushd "${PMD_GITHUB_IO_DIR}"; git add "${POST_FILE}"; popd |
| 183 | +echo |
| 184 | +echo "Created ${PMD_GITHUB_IO_DIR}/${POST_FILE}" |
| 185 | +echo |
| 186 | +echo "Please verify and commit and push..." |
| 187 | +echo "cd ${PMD_GITHUB_IO_DIR}" |
| 188 | +echo "git commit -m \"PMD For Eclipse ${RELEASE_VERSION}.${BUILDQUALIFIER} Released\"" |
| 189 | +echo "git push origin master" |
| 190 | +echo |
| 191 | +echo |
| 192 | +echo Done. |
0 commit comments