Skip to content

Hybrid EnKF-OI filter #3

Hybrid EnKF-OI filter

Hybrid EnKF-OI filter #3

Workflow file for this run

name: Release
on:
release:
types: [prereleased]
jobs:
Release:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@master
with:
python-version: 2.7
- name: Build Ford
env:
TOKEN: ${{ secrets.TOKEN }}
run: |
#
# We need one repository that has the fortran source we want to document
#
git clone https://dart-ucar:${TOKEN}@github.com/NCAR/DART_development.git
#
# and another to hold the copious amounts of output that we do not want
# as part of the public DART repository. This repo is one of convenience
# because it is the easiest way to distribute the documentation
#
git clone https://dart-ucar:${TOKEN}@github.com/NCAR/DART_FORD_docs.git
git config --global user.email "[email protected]"
git config --global user.name "dart-ucar"
cd DART_development
git pull
git checkout master
#
# Install the FORD pieces in the VM
#
sudo apt-get install graphviz
# sudo apt-get install findutils
pip install ford
pip install githubrelease
#
# grab the release version and sets a unique output directory name
#
VERSION=`git describe --tags --abbrev=0`
sed -i "s#ford_output#_api/$VERSION#g" docs/ford_config.md
#
ford docs/ford_config.md
#
# Replace string so it works next next time ... TJH has questions
sed -i "s/_api\/$VERSION/ford_output/g" docs/ford_config.md
#
# This adds the nsf footer and ncar logo to the header of each
# html page created by ford. This is because the layout from jekyll
# cannot be imported into ford.
#
cd docs/_api/$VERSION
cp ../../images/NCAR-contemp-logo-blue.png .
cp ../../images/NSF_AllWhite_bitmap_Logo.png .
find . -name "*.html" > temp.txt
sed -i "s/^.\///g" temp.txt
IFS=$'\n'
for LINE in $(cat temp.txt); do
sed -i "s/<div class=\"col-xs-12 col-md-4 col-md-pull-4\"><p class=\"text-center\"> DART was developed by DAReS<\/p><\/div>/<br><br><div><p align=\"center\"><a href=\"https:\/\/www.nsf.gov\/\" target=\"_blank\"><img src=\"..\/NSF_AllWhite_bitmap_Logo.png\" alt=NSF Logo\" align=\"right\"\/><\/a>This material is based upon work supported by the National Center for Atmospheric Research, a major facility sponsored by the National Science Foundation and managed by the University Corporation for Atmospheric Research. Any opinions, findings and conclusions or recommendations expressed in this material do not necessarily reflect the views of the National Science Foundation.<\/p><\/div>/g" $LINE
sed -i '0,/<\/button>/s/<\/button>/<\/button><a href=\"https:\/\/ncar.ucar.edu\"><img class=\"navbar-brand\" src=\"..\/NCAR-contemp-logo-blue.png\" alt=\"nsf logo\" align=\"left\"\/><\/a>/' $LINE
done
rm temp.txt
sed -i "s/..\/NCAR-contemp-logo-blue.png/NCAR-contemp-logo-blue.png/g" index.html
sed -i "s/..\/NSF_AllWhite_bitmap_Logo.png/NSF_AllWhite_bitmap_Logo.png/g" index.html
cd ..
#
#
# This tarball is for the release, it is moved out of the docs directory
# so that it is not pushed back to the repo.
tar -czvf $VERSION-documentation.tar.gz $VERSION
mv $VERSION-documentation.tar.gz ../../
#
#
# This saves the ford generated documentation to a different repo
# in order to save the main repository from blowing up.
mv $VERSION ../../../DART_FORD_docs
#
# Move to the output repository
# might want to move this to the end ... AFTER we finish
# mucking with the DART_development repo ...
#
cd ../../../DART_FORD_docs
# just in case something has changed
# git pull TJH ... this should not be needed
git add --all
git commit -m "new version of ford"
git push origin master
#
# Move back to the DART_development repository
# Updates any links in the markdown files that may go to
# the ford documentation
#
cd ../DART_development/docs/_api
cd ../pages
# Capture the old version number - no slashes
OLD=$(grep -o -m 1 "/v.*[0-9]/" Getting_Started.md | sed "s#/##g")
ls -1 *.md > temp.txt
IFS=$'\n'
# TJH Question: 1) why IFS ... not used
# TJH Question: 2) capture sed status and act accordingly
for LINE in $(cat temp.txt); do
sed -i "s#/$OLD/#/$VERSION/#g" $LINE
done
rm temp.txt
#
# Use graphql query to get the release name.
# This is very helpful for changing the main menu, and is somewhat
# convenient for not having to edit releases as much.
cd ../..
RESULT=$(curl -H "Authorization: bearer ${TOKEN}" -X POST -d " \
{ \
\"query\": \"query { repository(owner:"NCAR", name:"DART_development") { releases(last:1) { nodes { name } } } } \" \
} \
" https://api.github.com/graphql)
NAME=$(echo $RESULT | grep -o '"name":.*' | grep -o ':".*' | grep -Eo "[A-Z,a-z,0-9,_,-]{1,50}")
#
# Change the banner and pull-down menus for the gh-pages to include the reference to the release
# Find the line number of the release name and add a line below it with the new version.
if [[ $(grep "$NAME" docs/_data/mainmenu.yml) ]];
then LINE=$(grep -n "title: $NAME" docs/_data/mainmenu.yml | sed "s/:.*//g") && let "LINE++" && sed -i ''$LINE'i \ - title: '$VERSION'\n url: https://ncar.github.io/DART_FORD_docs/'$VERSION'/index.html' docs/_data/mainmenu.yml;
else LINE=$(grep -n "title: Releases" docs/_data/mainmenu.yml | sed "s/:.*//g") && let "LINE++" && let "LINE++" && sed -i ''$LINE'i \ - title: '$(echo $NAME)'\n - title: '$VERSION'\n url: https://ncar.github.io/DART_FORD_docs/'$VERSION'/index.html' docs/_data/mainmenu.yml;
fi
# update the markdown docs that reference this release
git add docs
git commit -m "building ford documents for website"
git push -u origin master
#
# This deletes pre-release and creates a new release using githubrelease
# more about githubrelease https://github.com/j0057/github-release
githubrelease --github-token ${TOKEN} release ${GITHUB_REPOSITORY} delete $VERSION
git push --delete origin $VERSION
githubrelease --github-token ${TOKEN} release ${GITHUB_REPOSITORY} create $VERSION --name $(echo $NAME)
githubrelease --github-token ${TOKEN} release ${GITHUB_REPOSITORY} publish $VERSION
githubrelease --github-token ${TOKEN} asset NCAR/DART_development upload $VERSION $VERSION-documentation.tar.gz