<commit_before>#!/usr/bin/env bash
set -e

# Make sure you prepared your PC for automative deployment
# https://github.com/checkstyle/checkstyle/wiki/How-to-make-a-release

SF_USER=romanivanov
RELEASE=$(xmlstarlet sel -N pom=http://maven.apache.org/POM/4.0.0 -t -m pom:project -v pom:version pom.xml | sed "s/-SNAPSHOT//")
PREV_RELEASE=$(git describe $(git rev-list --tags --max-count=1) | sed "s/checkstyle-//")

echo "PREVIOUS RELEASE version:"$PREV_RELEASE
echo "RELEASE version:"$RELEASE

if [[ -z $RELEASE ]]; then
  echo "Problem to calculate release version."
  exit 1
fi
if [[ -z $PREV_RELEASE ]]; then
  echo "Problem to calculate previous release version."
  exit 1
fi

#############################
echo "Please provide password for $SF_USER,<EMAIL>"
echo "exit" | ssh -t $SF_USER,<EMAIL> create

# Version bump in pom.xml - https://github.com/checkstyle/checkstyle/commits/master
mvn -e -Pgpg release:prepare -B -Darguments="-DskipTests -DskipITs -Dpmd.skip=true -Dspotbugs.skip=true -Djacoco.skip=true -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true"

# deployment of jars to maven central and publication of site to http://checkstyle.sourceforge.net/new-site/
mvn -e -Pgpg release:perform -Darguments='-Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true'

#############################

ssh $SF_USER,<EMAIL> << EOF


#Swap html content
cd /home/project-web/checkstyle
mv htdocs/new-site/ .
mv htdocs htdocs-$PREV_RELEASE
mv new-site htdocs
ln -s /home/project-web/checkstyle/reports htdocs/reports

#Archiving
tar cfz htdocs-$PREV_RELEASE.tar.gz htdocs-$PREV_RELEASE/
rm -rf htdocs-$PREV_RELEASE/

EOF

##############################

# go to folder where site was build and sources are already at required tag
cd target/checkout

#Generate all binaries, no clean to keep site resources just in case
mvn -e -Passembly package

#Publish them to sourceforce
FRS_PATH=/home/frs/project/checkstyle/checkstyle/$RELEASE
ssh $SF_USER,<EMAIL> "mkdir -p $FRS_PATH"
# !!! THIS WILL ASK A SOURCEFORGE PASSWORD !!
scp target/*.zip target/*.tar.gz target/*.jar $<EMAIL>:$FRS_PATH

#come back repo folder
cd ../../

##############################<commit_msg>config: update release.sh to update github.io<commit_after>#!/usr/bin/env bash
set -e

# Make sure you prepared your PC for automative deployment
# https://github.com/checkstyle/checkstyle/wiki/How-to-make-a-release

SF_USER=romanivanov
RELEASE=$(xmlstarlet sel -N pom=http://maven.apache.org/POM/4.0.0 -t -m pom:project -v pom:version pom.xml | sed "s/-SNAPSHOT//")
PREV_RELEASE=$(git describe $(git rev-list --tags --max-count=1) | sed "s/checkstyle-//")

echo "PREVIOUS RELEASE version:"$PREV_RELEASE
echo "RELEASE version:"$RELEASE

if [[ -z $RELEASE ]]; then
  echo "Problem to calculate release version."
  exit 1
fi
if [[ -z $PREV_RELEASE ]]; then
  echo "Problem to calculate previous release version."
  exit 1
fi

#############################
echo "Please provide password for $SF_USER,<EMAIL>"
echo "exit" | ssh -t $SF_USER,<EMAIL> create

# Version bump in pom.xml - https://github.com/checkstyle/checkstyle/commits/master
mvn -e -Pgpg release:prepare -B -Darguments="-DskipTests -DskipITs -Dpmd.skip=true -Dspotbugs.skip=true -Djacoco.skip=true -Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true -Dxml.skip=true"

# deployment of jars to maven central and publication of site to http://checkstyle.sourceforge.net/new-site/
mvn -e -Pgpg release:perform -Darguments='-Dcheckstyle.ant.skip=true -Dcheckstyle.skip=true'

#############################

ssh $SF_USER,<EMAIL> << EOF


#Swap html content
cd /home/project-web/checkstyle
mv htdocs/new-site/ .
mv htdocs htdocs-$PREV_RELEASE
mv new-site htdocs
ln -s /home/project-web/checkstyle/reports htdocs/reports

#Archiving
tar cfz htdocs-$PREV_RELEASE.tar.gz htdocs-$PREV_RELEASE/
rm -rf htdocs-$PREV_RELEASE/

EOF

##############################

# go to folder where site was build and sources are already at required tag
cd target/checkout

#Generate all binaries, no clean to keep site resources just in case
mvn -e -Passembly package

#Publish them to sourceforce
FRS_PATH=/home/frs/project/checkstyle/checkstyle/$RELEASE
ssh $SF_USER,<EMAIL> "mkdir -p $FRS_PATH"
# !!! THIS WILL ASK A SOURCEFORGE PASSWORD !!
scp target/*.zip target/*.tar.gz target/*.jar $<EMAIL>:$FRS_PATH

#come back repo folder
cd ../../

##############################

#update github.io
if [ -d "../checkstyle.github.io" ] ; then
  cd ../checkstyle.github.io
else
  cd ../
  # clone by ssh only to avoid passwords on push
  git clone git@github.com:checkstyle/checkstyle.github.io.git
  cd checkstyle.github.io
fi
git rm -rf *
git checkout HEAD -- CNAME
cp -R ../checkstyle/target/checkout/target/site/* .
git add .
git commit -m "release $RELEASE"
# we do force to avoid history changes, we do not need history as github.io shows only HEAD.
git push origin --force
{'fraction_non_alphanumeric': 0.16974169741697417, 'fraction_numerical': 0.0024600246002460025, 'mean_word_length': 4.33224043715847, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2695790', 'n_tokens_mistral': 1752, 'n_tokens_neox': 1643, 'n_words': 476}