2020-04-18 10:28:37 +02:00
|
|
|
#!/usr/bin/env bash
|
2018-10-28 16:55:48 +01:00
|
|
|
set -e
|
2015-09-18 11:25:30 +02:00
|
|
|
|
2017-05-27 20:33:03 +02:00
|
|
|
# Make sure, everything is English...
|
2018-09-02 14:51:23 +02:00
|
|
|
export LANG=C.UTF-8
|
2017-05-27 20:33:03 +02:00
|
|
|
|
2015-09-18 11:25:30 +02:00
|
|
|
# verify the current directory
|
|
|
|
if [ ! -f pom.xml -o ! -d ../pmd.github.io ]; then
|
2016-01-07 10:14:24 +01:00
|
|
|
echo "You seem to be in the wrong working directory or you don't have pmd.github.io checked out..."
|
2015-09-18 11:25:30 +02:00
|
|
|
echo
|
|
|
|
echo "Expected:"
|
|
|
|
echo "* You are currently in the pmd repository"
|
|
|
|
echo "* ../pmd.github.io is the pmd.github.io repository"
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-04-18 10:28:37 +02:00
|
|
|
LAST_VERSION=
|
2015-09-18 11:25:30 +02:00
|
|
|
RELEASE_VERSION=
|
|
|
|
DEVELOPMENT_VERSION=
|
|
|
|
CURRENT_BRANCH=
|
|
|
|
|
|
|
|
echo "-------------------------------------------"
|
|
|
|
echo "Releasing PMD"
|
|
|
|
echo "-------------------------------------------"
|
|
|
|
|
2020-12-04 17:34:09 +01:00
|
|
|
CURRENT_VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
|
2017-02-25 20:07:37 +01:00
|
|
|
RELEASE_VERSION=${CURRENT_VERSION%-SNAPSHOT}
|
2017-05-20 22:21:55 +02:00
|
|
|
MAJOR=$(echo $RELEASE_VERSION | cut -d . -f 1)
|
|
|
|
MINOR=$(echo $RELEASE_VERSION | cut -d . -f 2)
|
|
|
|
PATCH=$(echo $RELEASE_VERSION | cut -d . -f 3)
|
2017-07-01 18:56:33 +02:00
|
|
|
if [ "$PATCH" == "0" ]; then
|
|
|
|
NEXT_MINOR=$(expr ${MINOR} + 1)
|
|
|
|
NEXT_PATCH="0"
|
2020-04-18 10:28:37 +02:00
|
|
|
LAST_MINOR=$(expr ${MINOR} - 1)
|
|
|
|
LAST_PATCH="0"
|
2017-07-01 18:56:33 +02:00
|
|
|
else
|
|
|
|
# this is a bugfixing release
|
|
|
|
NEXT_MINOR="${MINOR}"
|
|
|
|
NEXT_PATCH=$(expr ${PATCH} + 1)
|
2020-04-18 10:28:37 +02:00
|
|
|
LAST_MINOR="${MINOR}"
|
|
|
|
LAST_PATCH=$(expr ${PATCH} - 1)
|
2017-07-01 18:56:33 +02:00
|
|
|
fi
|
2020-04-18 10:28:37 +02:00
|
|
|
LAST_VERSION="$MAJOR.$LAST_MINOR.$LAST_PATCH"
|
2017-07-01 18:56:33 +02:00
|
|
|
DEVELOPMENT_VERSION="$MAJOR.$NEXT_MINOR.$NEXT_PATCH"
|
2017-02-25 20:07:37 +01:00
|
|
|
DEVELOPMENT_VERSION="${DEVELOPMENT_VERSION}-SNAPSHOT"
|
|
|
|
|
2018-01-21 16:22:59 +01:00
|
|
|
# allow to override the next version, e.g. via "NEXT_VERSION=7.0.0 ./do-release.sh"
|
|
|
|
if [ "$NEXT_VERSION" != "" ]; then
|
|
|
|
DEVELOPMENT_VERSION="${NEXT_VERSION}-SNAPSHOT"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2017-02-25 20:07:37 +01:00
|
|
|
# http://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch
|
|
|
|
CURRENT_BRANCH=$(git symbolic-ref -q HEAD)
|
|
|
|
CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/}
|
|
|
|
CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD}
|
|
|
|
|
2020-04-18 10:28:37 +02:00
|
|
|
echo "LAST_VERSION: ${LAST_VERSION}"
|
|
|
|
echo "RELEASE_VERSION: ${RELEASE_VERSION} (this release)"
|
|
|
|
echo "DEVELOPMENT_VERSION: ${DEVELOPMENT_VERSION} (the next version after the release)"
|
2017-02-25 20:07:37 +01:00
|
|
|
echo "CURRENT_BRANCH: ${CURRENT_BRANCH}"
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Is this correct?"
|
|
|
|
echo
|
2020-04-18 10:28:37 +02:00
|
|
|
echo "Press enter to continue... (or CTRL+C to cancel)"
|
2017-02-25 20:07:37 +01:00
|
|
|
read
|
2015-09-18 11:25:30 +02:00
|
|
|
|
2020-04-18 10:28:37 +02:00
|
|
|
export LAST_VERSION
|
2015-09-18 11:25:30 +02:00
|
|
|
export RELEASE_VERSION
|
|
|
|
export DEVELOPMENT_VERSION
|
|
|
|
export CURRENT_BRANCH
|
|
|
|
|
2018-10-28 16:55:48 +01:00
|
|
|
RELEASE_RULESET="pmd-core/src/main/resources/rulesets/releases/${RELEASE_VERSION//\./}.xml"
|
2018-09-02 14:51:23 +02:00
|
|
|
|
2018-01-21 16:22:59 +01:00
|
|
|
echo "* Update date info in **docs/_config.yml**."
|
2018-08-15 04:08:15 +02:00
|
|
|
echo " date: $(date -u +%d-%B-%Y)"
|
2017-12-15 15:27:57 +01:00
|
|
|
echo
|
2020-04-24 12:24:47 +02:00
|
|
|
echo "* Update version info in **docs/_config.yml**."
|
|
|
|
echo " remove the SNAPSHOT from site.pmd.version"
|
|
|
|
echo
|
2018-08-15 04:08:15 +02:00
|
|
|
echo "* Ensure all the new rules are listed in the proper file:"
|
2018-05-30 09:01:00 +02:00
|
|
|
echo " ${RELEASE_RULESET}"
|
2015-09-18 11:25:30 +02:00
|
|
|
echo
|
2019-03-30 17:35:40 +01:00
|
|
|
echo "* Update **pmd-apex/src/main/resources/rulesets/apex/quickstart.xml** and"
|
2019-03-31 11:54:23 +02:00
|
|
|
echo " **pmd-java/src/main/resources/rulesets/java/quickstart.xml** with the new rules."
|
2019-03-30 17:35:40 +01:00
|
|
|
echo
|
2018-11-12 20:14:54 +01:00
|
|
|
echo "* Update **docs/pages/next_major_development.md** with the API changes for"
|
2020-05-29 09:01:21 +02:00
|
|
|
echo " the new release based on the release notes. Also add any deprecated rules to the list."
|
2018-11-12 20:14:54 +01:00
|
|
|
echo
|
2017-12-15 15:27:57 +01:00
|
|
|
echo "* Update **../pmd.github.io/_config.yml** to mention the new release"
|
|
|
|
echo
|
2019-03-31 11:54:23 +02:00
|
|
|
echo "* Update property \`pmd-designer.version\` in **pom.xml** to reference the latest pmd-designer release"
|
2019-03-11 15:30:33 +01:00
|
|
|
echo " See <https://search.maven.org/search?q=g:net.sourceforge.pmd%20AND%20a:pmd-ui&core=gav> for the available releases."
|
|
|
|
echo
|
2015-09-18 11:25:30 +02:00
|
|
|
echo "Press enter to continue..."
|
|
|
|
read
|
2018-09-30 11:05:18 +02:00
|
|
|
|
2020-04-18 10:28:37 +02:00
|
|
|
|
|
|
|
# calculating stats for release notes
|
|
|
|
|
|
|
|
STATS=$(
|
|
|
|
echo "### Stats"
|
|
|
|
echo "* $(git log pmd_releases/${LAST_VERSION}..HEAD --oneline --no-merges |wc -l) commits"
|
|
|
|
echo "* $(curl -s https://api.github.com/repos/pmd/pmd/milestones|jq ".[] | select(.title == \"$RELEASE_VERSION\") | .closed_issues") closed tickets & PRs"
|
|
|
|
echo "* Days since last release: $(( ( $(date +%s) - $(git log --max-count=1 --format="%at" pmd_releases/${LAST_VERSION}) ) / 86400))"
|
|
|
|
)
|
|
|
|
|
|
|
|
TEMP_RELEASE_NOTES=$(cat docs/pages/release_notes.md)
|
|
|
|
TEMP_RELEASE_NOTES=${TEMP_RELEASE_NOTES/\{\% endtocmaker \%\}/$STATS$'\n'$'\n'\{\% endtocmaker \%\}$'\n'}
|
|
|
|
echo "${TEMP_RELEASE_NOTES}" > docs/pages/release_notes.md
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Updated stats in release notes:"
|
|
|
|
echo "$STATS"
|
|
|
|
echo
|
2020-04-24 08:41:01 +02:00
|
|
|
echo "Please verify docs/pages/release_notes.md"
|
2020-04-18 10:28:37 +02:00
|
|
|
echo
|
2020-04-24 08:41:01 +02:00
|
|
|
echo "Press enter to continue..."
|
|
|
|
read
|
2020-04-18 10:28:37 +02:00
|
|
|
|
2018-09-30 11:05:18 +02:00
|
|
|
# install bundles needed for rendering release notes
|
2020-07-31 14:08:20 +02:00
|
|
|
bundle config set --local path vendor/bundle
|
|
|
|
bundle config set --local with release_notes_preprocessing
|
|
|
|
bundle install
|
2018-09-30 11:05:18 +02:00
|
|
|
|
|
|
|
export RELEASE_NOTES_POST="_posts/$(date -u +%Y-%m-%d)-PMD-${RELEASE_VERSION}.md"
|
|
|
|
echo "Generating ../pmd.github.io/${RELEASE_NOTES_POST}..."
|
2021-04-15 18:19:47 +02:00
|
|
|
NEW_RELEASE_NOTES=$(bundle exec docs/render_release_notes.rb docs/pages/release_notes.md | tail -n +6)
|
2018-10-03 11:30:24 +02:00
|
|
|
cat > ../pmd.github.io/${RELEASE_NOTES_POST} <<EOF
|
|
|
|
---
|
|
|
|
layout: post
|
|
|
|
title: PMD ${RELEASE_VERSION} released
|
|
|
|
---
|
|
|
|
${NEW_RELEASE_NOTES}
|
|
|
|
EOF
|
2018-09-30 11:05:18 +02:00
|
|
|
|
2015-09-18 11:25:30 +02:00
|
|
|
echo "Committing current changes (pmd)"
|
2018-05-29 17:11:40 -03:00
|
|
|
|
2018-05-30 09:01:00 +02:00
|
|
|
if [[ -e ${RELEASE_RULESET} ]]
|
|
|
|
then
|
|
|
|
git add ${RELEASE_RULESET}
|
2018-05-29 17:11:40 -03:00
|
|
|
fi
|
|
|
|
|
2015-09-18 11:25:30 +02:00
|
|
|
git commit -a -m "Prepare pmd release ${RELEASE_VERSION}"
|
|
|
|
(
|
|
|
|
cd ../pmd.github.io
|
2018-09-02 14:51:23 +02:00
|
|
|
git add ${RELEASE_NOTES_POST}
|
2019-10-31 18:27:57 +01:00
|
|
|
changes=$(git status --porcelain 2>/dev/null| egrep "^[AMDRC]" | wc -l)
|
|
|
|
if [ $changes -gt 0 ]; then
|
|
|
|
echo "Committing current changes (pmd.github.io)"
|
|
|
|
git commit -a -m "Prepare pmd release ${RELEASE_VERSION}" && git push
|
|
|
|
fi
|
2015-09-18 11:25:30 +02:00
|
|
|
)
|
|
|
|
|
2017-05-05 11:17:25 +02:00
|
|
|
./mvnw -B release:clean release:prepare \
|
2015-09-18 11:25:30 +02:00
|
|
|
-Dtag=pmd_releases/${RELEASE_VERSION} \
|
|
|
|
-DreleaseVersion=${RELEASE_VERSION} \
|
2019-11-01 09:51:53 +01:00
|
|
|
-DdevelopmentVersion=${DEVELOPMENT_VERSION} \
|
|
|
|
-Pgenerate-rule-docs
|
2015-09-18 11:25:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
echo
|
2020-12-04 17:34:09 +01:00
|
|
|
echo "Tag has been pushed.... now check github actions: <https://github.com/pmd/pmd/actions>"
|
2015-09-18 11:25:30 +02:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "Press enter to continue..."
|
|
|
|
read
|
|
|
|
|
|
|
|
echo
|
2018-02-25 12:05:56 +01:00
|
|
|
echo "Check the milestone on github:"
|
|
|
|
echo "<https://github.com/pmd/pmd/milestones>"
|
|
|
|
echo " --> move any open issues to the next milestone, close the current milestone"
|
2015-09-18 11:25:30 +02:00
|
|
|
echo
|
2017-02-25 20:07:37 +01:00
|
|
|
echo
|
|
|
|
echo "Prepare Next development version:"
|
2018-01-21 16:51:52 +01:00
|
|
|
echo "* Update version/date info in **docs/_config.yml**."
|
2020-05-24 18:14:55 +02:00
|
|
|
echo " move version to previous_version, increase version, make sure it is a SNAPSHOT version"
|
|
|
|
echo " otherwise the javadoc links won't work during development"
|
|
|
|
echo " also update the date, e.g. ??-month-year."
|
2015-09-18 11:25:30 +02:00
|
|
|
echo
|
2018-05-29 16:08:48 -03:00
|
|
|
echo
|
|
|
|
echo "Press enter to continue..."
|
|
|
|
read
|
|
|
|
|
2018-05-29 17:42:27 -03:00
|
|
|
# update release_notes_old
|
2018-05-30 09:01:00 +02:00
|
|
|
OLD_RELEASE_NOTES=$(tail -n +8 docs/pages/release_notes_old.md)
|
|
|
|
echo "$(head -n 7 docs/pages/release_notes_old.md)" > docs/pages/release_notes_old.md
|
2018-05-29 17:42:27 -03:00
|
|
|
echo "$NEW_RELEASE_NOTES" >> docs/pages/release_notes_old.md
|
2018-05-30 09:01:00 +02:00
|
|
|
echo >> docs/pages/release_notes_old.md
|
2018-05-29 17:42:27 -03:00
|
|
|
echo "$OLD_RELEASE_NOTES" >> docs/pages/release_notes_old.md
|
|
|
|
|
2018-05-29 16:08:48 -03:00
|
|
|
# reset release notes template
|
|
|
|
cat > docs/pages/release_notes.md <<EOF
|
2017-08-15 14:08:48 +02:00
|
|
|
---
|
|
|
|
title: PMD Release Notes
|
|
|
|
permalink: pmd_release_notes.html
|
|
|
|
keywords: changelog, release notes
|
|
|
|
---
|
2015-09-18 11:25:30 +02:00
|
|
|
|
2018-08-19 16:28:12 +02:00
|
|
|
## {{ site.pmd.date }} - {{ site.pmd.version }}
|
2015-09-18 11:25:30 +02:00
|
|
|
|
2018-08-15 04:08:15 +02:00
|
|
|
The PMD team is pleased to announce PMD {{ site.pmd.version }}.
|
2017-02-25 20:07:37 +01:00
|
|
|
|
2018-08-15 04:08:15 +02:00
|
|
|
This is a {{ site.pmd.release_type }} release.
|
2015-09-18 11:25:30 +02:00
|
|
|
|
2018-09-02 14:51:23 +02:00
|
|
|
{% tocmaker is_release_notes_processor %}
|
2015-09-18 11:25:30 +02:00
|
|
|
|
2017-02-25 20:07:37 +01:00
|
|
|
### New and noteworthy
|
2015-09-18 11:25:30 +02:00
|
|
|
|
2017-02-25 20:07:37 +01:00
|
|
|
### Fixed Issues
|
2015-09-18 11:25:30 +02:00
|
|
|
|
2017-02-25 20:07:37 +01:00
|
|
|
### API Changes
|
|
|
|
|
|
|
|
### External Contributions
|
2015-09-18 11:25:30 +02:00
|
|
|
|
2018-08-18 17:39:29 +02:00
|
|
|
{% endtocmaker %}
|
|
|
|
|
2015-09-18 11:25:30 +02:00
|
|
|
EOF
|
2018-05-29 16:08:48 -03:00
|
|
|
|
2015-09-18 11:25:30 +02:00
|
|
|
git commit -a -m "Prepare next development version"
|
2017-02-25 20:07:37 +01:00
|
|
|
git push origin ${CURRENT_BRANCH}
|
2018-06-26 09:44:02 +02:00
|
|
|
./mvnw -B release:clean
|
2015-09-18 11:25:30 +02:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo
|
2017-02-25 20:07:37 +01:00
|
|
|
echo "Verify the new release on github: <https://github.com/pmd/pmd/releases/tag/pmd_releases/${RELEASE_VERSION}>"
|
2021-04-18 19:08:51 +02:00
|
|
|
echo "and the news entry at <https://sourceforge.net/p/pmd/news/>"
|
2015-09-18 11:25:30 +02:00
|
|
|
echo
|
2020-12-04 17:34:09 +01:00
|
|
|
echo "* Wait until the new version is synced to maven central and appears as latest version in"
|
2020-07-31 14:11:30 +02:00
|
|
|
echo " <https://repo.maven.apache.org/maven2/net/sourceforge/pmd/pmd/maven-metadata.xml>."
|
2018-08-17 10:49:23 +02:00
|
|
|
echo "* Send out an announcement mail to the mailing list:"
|
2015-09-18 11:25:30 +02:00
|
|
|
echo
|
2017-02-25 21:12:18 +01:00
|
|
|
echo "To: PMD Developers List <pmd-devel@lists.sourceforge.net>"
|
2021-04-18 19:08:51 +02:00
|
|
|
echo "Subject: [ANNOUNCE] PMD ${RELEASE_VERSION} released"
|
2018-02-25 12:05:56 +01:00
|
|
|
echo
|
2021-04-18 19:08:51 +02:00
|
|
|
echo " You can copy the same text from <https://sourceforge.net/p/pmd/news/>."
|
2017-02-25 20:07:37 +01:00
|
|
|
echo
|
2015-09-18 11:25:30 +02:00
|
|
|
echo
|
2020-02-08 12:45:40 +01:00
|
|
|
tweet="PMD ${RELEASE_VERSION} released: https://github.com/pmd/pmd/releases/tag/pmd_releases/${RELEASE_VERSION} #PMD"
|
|
|
|
tweet="${tweet// /%20}"
|
|
|
|
tweet="${tweet//:/%3A}"
|
|
|
|
tweet="${tweet//#/%23}"
|
|
|
|
tweet="${tweet//\//%2F}"
|
|
|
|
tweet="${tweet//$'\r'//}"
|
|
|
|
tweet="${tweet//$'\n'//%0A}"
|
|
|
|
echo "* Tweet about this release on https://twitter.com/pmd_analyzer:"
|
|
|
|
echo " <https://twitter.com/intent/tweet?text=$tweet>"
|
|
|
|
echo
|
2015-09-18 11:25:30 +02:00
|
|
|
echo "------------------------------------------"
|
|
|
|
echo "Done."
|
|
|
|
echo "------------------------------------------"
|
|
|
|
echo
|
|
|
|
|
|
|
|
|