From 54319760dc494eaea9167372fe7643902b014554 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= <git@maximilian-kessler.de>
Date: Fri, 22 Oct 2021 20:14:44 +0200
Subject: [PATCH] set up travis

---
 .travis.yml                           | 13 +++---------
 .travis/get_build_repo_from_origin.sh | 16 +++++++++++++++
 .travis/travis_build.sh               | 29 ++++++---------------------
 Makefile                              | 12 +++++++----
 4 files changed, 33 insertions(+), 37 deletions(-)
 create mode 100755 .travis/get_build_repo_from_origin.sh

diff --git a/.travis.yml b/.travis.yml
index 1fd2351..02b2b62 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,15 +15,8 @@ install:
     - pip install GitPython
       
 script:
-    - export COMMIT_MSG=$(python3 -c 'from git_version import get_deploy_message; print(get_deploy_message())')
-    - python3 -c 'from build import build; build("build/LatexPackages/")'
-    - cd build
-    - zip -r LatexPackages.zip LatexPackages
-    - tree -H '.' -I "index.html" -D --charset utf-8 -T "LatexPackages" > index.html
-    - cd ..
-
-after_success:
-    
+    - source ./.travis/get_build_repo_from_origin.sh
+    - source ./.travis/travis_build.sh
 
 deploy:
     - provider: pages
@@ -42,7 +35,7 @@ deploy:
     - provider: pages
       edge: true
       github-token: $GITHUB_TOKEN
-      local-dir: build/LatexPackages
+      local-dir: build/LatexPackagesBuild
       repo: kesslermaximilian/LatexPackagesBuild
       commiter_from_gh: true
       allow_empty_commit: true
diff --git a/.travis/get_build_repo_from_origin.sh b/.travis/get_build_repo_from_origin.sh
new file mode 100755
index 0000000..26a9db1
--- /dev/null
+++ b/.travis/get_build_repo_from_origin.sh
@@ -0,0 +1,16 @@
+# ! /bin/sh
+git clone https://github.com/kesslermaximilian/LatexPackagesBuild.git build/LatexPackagesBuild
+cd build/LatexPackagesBuild
+REMOTE_BRANCH=$(git branch -a | sed -n '/remotes\/origin\/.*-build/p' | sed 's/remotes\/origin\///g' | sed 's/-build//g' | sed 's/[[:space:]]//g' | sed -n "/^${TRAVIS_BRANCH}$/p")
+
+echo ${REMOTE_BRANCH}
+
+if [ "$REMOTE_BRANCH" = "" ];then
+    echo "This is the first build on this branch, creating new branch in build repository to push to"
+    git checkout --orphan ${TRAVIS_BRANCH}-build
+    ls -ra | sed '/^\.git$/d' | sed '/^\.\.$/d' | sed '/^\.$/d' |  xargs -r git rm --cached
+    ls -ra | sed '/^\.git$/d' | sed '/^\.\.$/d' | sed '/^\.$/d' |  xargs -r rm -rf
+else
+    echo "Checking out remote branch from last build"
+    git checkout -b ${REMOTE_BRANCH}-build origin/${REMOTE_BRANCH}-build
+fi
diff --git a/.travis/travis_build.sh b/.travis/travis_build.sh
index 48b0f42..e90f320 100755
--- a/.travis/travis_build.sh
+++ b/.travis/travis_build.sh
@@ -1,23 +1,6 @@
-# ! /bin/sh
-TRAVIS_BRANCH=algebraic-geometry
-TRAVIS_BUILD_DIR=/home/maximilian/LatexPackages
-
-
-cd ${TRAVIS_BUILD_DIR}
-rm -rf LatexPackagesBuild
-
-git clone https://github.com/kesslermaximilian/LatexPackagesBuild.git LatexPackagesBuild
-cd LatexPackagesBuild
-REMOTE_BRANCH=$(git branch -a | sed -n '/remotes\/origin\/.*-build/p' | sed 's/remotes\/origin\///g' | sed 's/-build//g' | sed 's/[[:space:]]//g' | sed -n "/^${TRAVIS_BRANCH}$/p")
-
-echo ${REMOTE_BRANCH}
-
-if [ "$REMOTE_BRANCH" = "" ];then
-    echo "This is the first build on this branch, creating new branch in build repository to push to"
-    git checkout --orphan ${TRAVIS_BRANCH}-build
-    ls -ra | sed '/^\.git$/d' | sed '/^\.\.$/d' | sed '/^\.$/d' |  xargs -r git rm --cached
-    ls -ra | sed '/^\.git$/d' | sed '/^\.\.$/d' | sed '/^\.$/d' |  xargs -r rm -rf
-else
-    echo "Checking out remote branch from last build"
-    git checkout -b ${REMOTE_BRANCH}-build origin/${REMOTE_BRANCH}-build
-fi
+export COMMIT_MSG=$(python3 print_deploy_message.py)
+make travis
+cd build
+zip -r LatexPackages.zip LatexPackagesBuild
+tree -H '.' -I "index.html" -D --charset utf-8 -T "LatexPackages" > index.html
+cd ..
diff --git a/Makefile b/Makefile
index f3d5239..9e8113d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,12 @@
 .PHONY: build
-BUILD_FLAGS=--source-dir src --build-dir build --recursive --git-version --pytex-version --license --author "Maximilian Keßler" --pytex-info-text --extra-header ".build/header_info.txt" --name "prepend-author"
+BUILD_FLAGS=--recursive --git-version --pytex-version --license --author "Maximilian Keßler" --pytex-info-text --extra-header ".build/header_info.txt" --name "prepend-author"
+BUILD_DIRS= --source-dir src --build-dir build
 
 build: .initsubmodulelock
-	@python3 build.py ${BUILD_FLAGS}
+	@python3 build.py ${BUILD_DIRS} ${BUILD_FLAGS}
 
 dirty: .initsubmodulelock
-	@python3 build.py ${BUILD_FLAGS} --allow-dirty
+	@python3 build.py ${BUILD_DIRS} ${BUILD_FLAGS} --allow-dirty
 
 init: .initsubmodulelock .gitconfiglock
 
@@ -25,4 +26,7 @@ config: .gitconfiglock
 
 
 clean:
-	-rm -r build/
+	@-rm -r build/
+
+travis:
+	@python3 build.py --source-dir src --build-dir build/LatexPackagesBuild ${BUILD_FLAGS}