|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +echo This is not meant to be run automatically. |
| 4 | + |
| 5 | +exit |
| 6 | + |
| 7 | +set -e |
| 8 | + |
| 9 | + |
| 10 | +# Make sure the build is ok via |
| 11 | +mvn -f aggregate clean verify site javadoc:jar |
| 12 | + |
| 13 | +echo |
| 14 | +echo Browse to |
| 15 | +echo "file://$PWD/target/site" |
| 16 | +echo and check the findbugs and jacoco reports. |
| 17 | + |
| 18 | +echo |
| 19 | +echo Check https://central.sonatype.org/pages/apache-maven.html#nexus-staging-maven-plugin-for-deployment-and-release |
| 20 | +echo and make sure you have the relevant credentials in your ~/.m2/settings.xml |
| 21 | + |
| 22 | +echo |
| 23 | +echo Check https://search.maven.org/#search%7Cga%7C1%7Cowasp-java-html-sanitizer |
| 24 | +echo and make sure that the current POM release number is max. |
| 25 | + |
| 26 | +# Pick a release version |
| 27 | +export DATE_STAMP="$(date +'%Y%m%d')" |
| 28 | +export NEW_VERSION="$DATE_STAMP"".1" |
| 29 | +export NEW_DEV_VERSION="$DATE_STAMP"".2-SNAPSHOT" |
| 30 | + |
| 31 | +cd ~/work |
| 32 | +export RELEASE_CLONE="$PWD/html-san-release" |
| 33 | +rm -rf "$RELEASE_CLONE" |
| 34 | +cd "$(dirname "$RELEASE_CLONE")" |
| 35 | +git clone git@github.com:OWASP/java-html-sanitizer.git \ |
| 36 | + "$(basename "$RELEASE_CLONE")" |
| 37 | +cd "$RELEASE_CLONE" |
| 38 | + |
| 39 | +# Update the version |
| 40 | +# mvn release:update-versions puts -SNAPSHOT on the end no matter what |
| 41 | +# so this is a two step process. |
| 42 | +export VERSION_PLACEHOLDER=99999999999999-SNAPSHOT |
| 43 | +mvn -f aggregate \ |
| 44 | + release:update-versions \ |
| 45 | + -DautoVersionSubmodules=true \ |
| 46 | + -DdevelopmentVersion="$VERSION_PLACEHOLDER" |
| 47 | +find . -name pom.xml \ |
| 48 | + | xargs perl -i.placeholder -pe "s/$VERSION_PLACEHOLDER/$NEW_VERSION/g" |
| 49 | + |
| 50 | +# Make sure the change log is up-to-date. |
| 51 | +perl -i.bak \ |
| 52 | + -pe 'if (m/^ [*] / && !$added) { $_ = qq( * Release $ENV{"NEW_VERSION"}\n$_); $added = 1; }' \ |
| 53 | + change_log.md |
| 54 | + |
| 55 | +"$EDITOR" change_log.md |
| 56 | + |
| 57 | +# A dry run. |
| 58 | +mvn -f aggregate clean source:jar javadoc:jar verify \ |
| 59 | + -DperformRelease=true |
| 60 | + |
| 61 | +# Commit and tag |
| 62 | +git commit -am "Release candidate $NEW_VERSION" |
| 63 | +git tag -m "Release $NEW_VERSION" -s "$NEW_VERSION" |
| 64 | + |
| 65 | +# Actually deploy. |
| 66 | +mvn -f aggregate clean source:jar javadoc:jar verify deploy:deploy \ |
| 67 | + -DperformRelease=true |
| 68 | + |
| 69 | +# Bump the development version. |
| 70 | +find . -name pom.xml.placeholder -exec |
| 71 | +find . -name pom.xml \ |
| 72 | + | xargs perl -i.placeholder \ |
| 73 | + -pe "s/99999999999999-SNAPSHOT/$NEW_DEV_VERSION/" |
| 74 | + |
| 75 | +git commit -am "Bumped dev version" |
| 76 | + |
| 77 | +git push origin master |
| 78 | + |
| 79 | +# Now Release |
| 80 | +echo '1. Go to oss.sonatype.org' |
| 81 | +echo '2. Look under staging repositories for one named' |
| 82 | +echo ' comgooglecodeowasp-java-html-sanitizer-...' |
| 83 | +echo '3. Close it.' |
| 84 | +echo '4. Refresh until it is marked "Closed".' |
| 85 | +echo '5. Check that its OK.' |
| 86 | +echo '6. Release it.' |
0 commit comments