Skip to content

Commit

Permalink
Upload the bibliography on successful builds of the master branch (#9769
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sjoelund committed Nov 25, 2022
1 parent 77b29d0 commit 8bfd4bd
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 29 deletions.
41 changes: 38 additions & 3 deletions Jenkinsfile
Expand Up @@ -213,9 +213,10 @@ pipeline {
sh "make -f Makefile.in -j${common.numLogicalCPU()} --output-sync=recurse bom-error utf8-error thumbsdb-error spellcheck"
sh '''
cd doc/bibliography
mkdir -p /tmp/openmodelica.org-bibgen
sh generate.sh /tmp/openmodelica.org-bibgen
mkdir -p openmodelica.org-bibgen
sh generate.sh "$PWD/openmodelica.org-bibgen"
'''
stash name: 'bibliography', includes: 'doc/bibliography/openmodelica.org-bibgen/*.md'
}
}
}
Expand Down Expand Up @@ -806,7 +807,41 @@ pipeline {
githubNotify status: 'SUCCESS', description: 'Skipping CLA checks on omlib-staging', context: 'license/CLA'
sshagent (credentials: ['Hudson-SSH-Key']) {
sh 'ssh-keyscan github.com >> ~/.ssh/known_hosts'
sh 'git push git@github.com:OpenModelica/OpenModelica.git omlib-staging:master || (echo "Trying to update the repository if that is the problem" ; git pull --rebase && git push --force git@github.com:OpenModelica/OpenModelica.git omlib-staging:omlib-staging & false)'
sh 'git push git@github.com:OpenModelica/OpenModelica.git omlib-staging:master || (echo "Trying to update the repository if that is the problem" ; git pull --rebase && git push --force git@github.com:OpenModelica/OpenModelica.git omlib-staging:omlib-staging && false)'
}
}
}
stage('push-bibliography') {
agent {
label 'linux'
}
when {
beforeAgent true
branch 'master'
expression { return currentBuild.currentResult == 'SUCCESS' }
}
options {
skipDefaultCheckout true
}
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '*/main']],
extensions: scm.extensions + [[$class: 'CleanCheckout']],
userRemoteConfigs: [[credentialsId: 'git-credentials', url: 'https://github.com/OpenModelica/www.openmodelica.org.git']]
])
unstash 'bibliography' // 'doc/bibliography/openmodelica.org-bibgen'
sh "git remote -v | grep www.openmodelica.org"
sh "mv doc/bibliography/openmodelica.org-bibgen/*.md content/research/"
sh "git add content/research/*.md"
sshagent (credentials: ['Hudson-SSH-Key']) {
sh """
if ! git diff-index --quiet HEAD; then
git commit -m 'Updated bibliography'
ssh-keyscan github.com >> ~/.ssh/known_hosts
git push git@github.com:OpenModelica/www.openmodelica.org.git main:main
fi
"""
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions doc/bibliography/.gitignore
@@ -0,0 +1,4 @@
*.html
*.md
*.tmp
*.aux
13 changes: 7 additions & 6 deletions doc/bibliography/bib2html.sh
Expand Up @@ -4,15 +4,16 @@
# $2: basename of the bib-file
# $3: target encoding
# $4: path to where the files are stored (relative on the server)
rm -f $1.bibinc
rm -f $1.md
cp $1.title $1.md
for year in `grep -o '[0-9][0-9][0-9][0-9]' $1.cite | sort -ru`; do
grep $year $1.cite > $1.cite.$year
bibtex2html -r -d --note supervisor --note examiner -charset utf8 -citefile $1.cite.$year -nf pdf pdf -nodoc -noheader -nofooter $2.bib || exit 1
iconv -f utf8 -t $3 $2.html > $1.bibinc.tmp || exit 1
sed -i "s/href=\"$2/href=\"$4$2/" $1.bibinc.tmp || exit 1
echo "<h3>$year</h3>" >> $1.bibinc
cat $1.bibinc.tmp >> $1.bibinc
iconv -f utf8 -t $3 $2.html > $1.md.tmp || exit 1
sed -i "s,href=\"$2_bib.html,href=\"$4$2_bib," $1.md.tmp || exit 1
echo "<h3>$year</h3>" >> $1.md
cat $1.md.tmp >> $1.md
rm $1.cite.$year
done

cp $1.bibinc $1.html
cp $1.md $1.html
File renamed without changes.
3 changes: 3 additions & 0 deletions doc/bibliography/conference-papers.title
@@ -0,0 +1,3 @@
---
title: "Conference Papers"
---
18 changes: 12 additions & 6 deletions doc/bibliography/generate.sh
@@ -1,11 +1,17 @@
#!/bin/sh
rm -f *.bibinc *.html ../*.bibinc ../marsj_bib.html
#!/bin/sh -x
rm -f *.md *.html
test -z "$1" && echo "You need to specify output directory (e.g. /media/ida-home/www-pub/ )" && exit

for type in papers msc journals phd; do
./bib2html.sh $type openmodelica utf8 bibliography\\/ || exit 1
for type in conference-papers master-theses journal-papers phd-and-licentiate-theses; do
./bib2html.sh $type openmodelica utf8 /research/ || exit 1
done

bibtex2html -a -charset utf8 openmodelica.bib || exit 1
bibtex2html -a -nodoc -noheader -nofooter -charset utf8 openmodelica.bib || exit 1

mv *.bibinc openmodelica_bib.html openmodelica.html $1
sed -i "s,href=\"openmodelica_bib.html,href=\"/research/openmodelica_bib," openmodelica.html
sed -i -e "s,href=\"openmodelica.html,href=\"/research/openmodelica," -e "s,<h1>.*</h1>,," openmodelica_bib.html

cat openmodelica_bib.title openmodelica_bib.html > openmodelica_bib.md
cat openmodelica.title openmodelica.html > openmodelica.md
rm openmodelica.html openmodelica_bib.html
mv *.md $1
File renamed without changes.
3 changes: 3 additions & 0 deletions doc/bibliography/journal-papers.title
@@ -0,0 +1,3 @@
---
title: "Journal Articles"
---
File renamed without changes.
3 changes: 3 additions & 0 deletions doc/bibliography/master-theses.title
@@ -0,0 +1,3 @@
---
title: "Master Theses"
---
3 changes: 3 additions & 0 deletions doc/bibliography/openmodelica.title
@@ -0,0 +1,3 @@
---
title: "OpenModelica Bibliography"
---
3 changes: 3 additions & 0 deletions doc/bibliography/openmodelica_bib.title
@@ -0,0 +1,3 @@
---
title: "openmodelica.bib"
---
File renamed without changes.
3 changes: 3 additions & 0 deletions doc/bibliography/phd-and-licentiate-theses.title
@@ -0,0 +1,3 @@
---
title: "Doctoral and Licentiate Theses"
---
14 changes: 0 additions & 14 deletions doc/bibliography/upload.sh

This file was deleted.

0 comments on commit 8bfd4bd

Please sign in to comment.