HoC2 started #439
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automated Build | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- data/** | |
- configs/** | |
- layouts/** | |
- .github/workflows/** | |
workflow_dispatch: | |
env: | |
THERION_VERSION: 6.2.1 | |
THERION_PATH: ./therion-6.2.1 | |
EXPECTED_OUTPUTS: >- | |
brezno_pod_vrhom_planje.3d | |
brezno_pod_vrhom_planje_plan_EN.pdf | |
brezno_pod_vrhom_planje_ee_EN.pdf | |
brezno_pod_vrhom_planje_plan_EN.svg | |
brezno_pod_vrhom_planje_ee_EN.svg | |
nakljucja.3d | |
nakljucja_plan_EN.pdf | |
nakljucja_ee_EN.pdf | |
nakljucja_plan_SLO.pdf | |
nakljucja_ee_SLO.pdf | |
nakljucja_plan_EN.svg | |
nakljucja_ee_EN.svg | |
nakljucja_plan_SLO.svg | |
nakljucja_ee_SLO.svg | |
m2_m16_m18.3d | |
m2_m16_m18_plan_SLO.pdf | |
m2_m16_m18_plan_SLO.svg | |
m2_m16_m18_plan_ENG.pdf | |
m2_m16_m18_plan_ENG.svg | |
m2_m16_m18_EE_SLO.pdf | |
m2_m16_m18_EE_SLO.svg | |
m2_m16_m18_EE_ENG.pdf | |
m2_m16_m18_EE_ENG.svg | |
plateau.3d | |
plateau.kml | |
primadona_ubend_mona_tip_plan_SLO.pdf | |
primadona_ubend_mona_tip_plan_SLO.svg | |
primadona_ubend_mona_tip_plan_ENG.pdf | |
primadona_ubend_mona_tip_plan_ENG.svg | |
primadona_ubend_mona_tip_EE_ENG.pdf | |
primadona_ubend_mona_tip_EE_ENG.svg | |
primadona_ubend_mona_tip_EE_SLO.pdf | |
primadona_ubend_mona_tip_EE_SLO.svg | |
primadona_ubend_mona_tip.3d | |
symbology.pdf | |
symbology.svg | |
system_migovec.3d | |
system_migovec_plan_SLO.pdf | |
system_migovec_plan_SLO.svg | |
system_migovec_plan_ENG.pdf | |
system_migovec_plan_ENG.svg | |
system_migovec_EE_SLO.pdf | |
system_migovec_EE_SLO.svg | |
system_migovec_EE_ENG.pdf | |
system_migovec_EE_ENG.svg | |
vrtnarija.3d | |
vrtnarija_EE_SLO.pdf | |
vrtnarija_EE_SLO.svg | |
vrtnarija_EE_ENG.pdf | |
vrtnarija_EE_ENG.svg | |
vrtnarija_plan_SLO.pdf | |
vrtnarija_plan_SLO.svg | |
vrtnarija_plan_ENG.pdf | |
vrtnarija_plan_ENG.svg | |
# Cause seg faults: | |
# m2_m16_m18.lox | |
# primadona_ubend_mona_tip.lox | |
# vrtnarija.lox | |
# system_migovec.lox | |
# plateau.lox | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Cache Therion | |
id: cache-therion | |
uses: actions/cache@v1 | |
with: | |
path: ${{ env.THERION_PATH }}/bin | |
key: ${{ runner.os }}-${{ env.THERION_VERSION }} | |
#========================= INSTALL DEPENDENCIES ========================# | |
- name: Run apt update | |
run: sudo apt update | |
- name: Install Therion compilation dependencies | |
if: steps.cache-therion.outputs.cache-hit != 'true' | |
run: sudo apt install -y bwidget lcdf-typetools libtk-img-dev libvtk7-dev libwxgtk3.0-gtk3-dev tcl-dev survex texlive-latex-base libfmt-dev # Pre-installed: gcc ghostscript imagemagick libfreetype6-dev libjpeg-dev libpng-dev zlib1g zlib1g-dev | |
- name: Install Therion runtime dependencies | |
run: sudo apt install -y libproj-dev lcdf-typetools texlive-metapost survex libfmt-dev | |
- name: Download and unpack Therion | |
if: steps.cache-therion.outputs.cache-hit != 'true' | |
run: | | |
curl https://github.com/therion/therion/archive/v${THERION_VERSION}.tar.gz -L -O | |
tar xvzf v${THERION_VERSION}.tar.gz | |
- name: Build Therion | |
if: steps.cache-therion.outputs.cache-hit != 'true' | |
run: | | |
make -C $THERION_PATH | |
mkdir ${THERION_PATH}/bin | |
mv ${THERION_PATH}/therion ${THERION_PATH}/bin/therion | |
- name: Install svgo | |
run: sudo npm install -g svgo | |
#=========================== GENERATE OUTPUT ===========================# | |
- name: Generate output files | |
run: for file in configs/automation/*.thconfig; do echo "Generating $file" && ${THERION_PATH}/bin/therion -q $file || echo "Generating $file failed"; done | |
- name: Check outputs exist | |
run: | | |
for file in $EXPECTED_OUTPUTS; do | |
if test ! -f outputs/$file; then | |
GONE="$GONE $file" | |
fi | |
done | |
if test -n "$GONE"; then | |
echo "These outputs are missing: $GONE" | |
exit 1 | |
fi | |
- name: Create GPX from KML | |
run: python3 ./scripts/kml_to_gpx.py --fname_in ./outputs/plateau.kml --fname_out ./outputs/plateau.gpx | |
#=========================== PROCESS OUTPUT ===========================# | |
- name: Compress PDFs | |
run: | | |
for file in ./outputs/*.pdf; do | |
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=temp.pdf $file; | |
mv temp.pdf $file; | |
done | |
- name: Replace invalid characters in SVGs | |
# See https://github.com/svg/svgo/issues/1498 | |
run: | | |
for file in ./outputs/*.svg; do | |
sed -i 's/\&/\&/' $file; | |
sed -i 's/\</\</' $file; | |
sed -i 's/\>/\>/' $file; | |
done | |
- name: Compress SVGs | |
run: svgo --config .github/svgo.conf.js -f ./outputs/ | |
- name: Add fonts to SVGs | |
run: | | |
for file in ./outputs/*.svg; do | |
sed -i 's/<\/svg>//' $file | |
echo "<style>$(cat docs/static/fonts/open-sans.css | tr -d '[:space:]')text{font-family: \"Open Sans\"}</style></svg>" >>$file | |
done | |
#=========================== CREATE LISTING ===========================# | |
- name: Generate listing | |
run: python3 ./scripts/create_file_listing.py ./outputs/ ./outputs/listing.json | |
#=========================== GENERATE STATS ===========================# | |
- name: Generate stats | |
run: python3 ./scripts/create_system_stats.py data/system_migovec.th --json ./outputs/stats.json --therion-path ${THERION_PATH}/bin/therion | |
#=============================== UPLOADS ===============================# | |
- name: Upload Files | |
uses: "marvinpinto/action-automatic-releases@latest" | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
title: Build ${{ github.run_number }} | |
automatic_release_tag: "latest" | |
prerelease: false | |
files: | | |
./outputs/listing.json | |
./outputs/stats.json | |
./outputs/*.3d | |
./outputs/*.lox | |
./outputs/*.pdf | |
./outputs/*.svg | |
./outputs/*.kml | |
./outputs/*.gpx |