Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build on Travis and deploy to Netlify #113

Merged
merged 8 commits into from
Jul 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
language: python
python:
- 3.7
os: linux
dist: xenial
cache:
pip: true

if: type != pull_request AND branch =~ /^(manual-)/

install:
- sudo apt-get update && sudo apt-get install -y texlive texlive-xetex texlive-latex-extra latexmk xindy
- npm install -g netlify-cli
- export PATH="$(npm prefix -g)/bin:$PATH"
- pip install -r requirements.txt

script:
- mkdir html
- git remote rename origin fork
- git remote add origin https://github.com/mixxxdj/manual.git
- git fetch origin
- git branch -r
- export LATEST_BRANCH="$(git branch -r | grep -Po 'origin/manual-\d+\.\d+\.x' | sort | tail -n 1)"
- echo "Building from branch ${LATEST_BRANCH}"
- git checkout "${LATEST_BRANCH}"
- sh build_manual.sh

deploy:
provider: script
skip_cleanup: true
script: netlify deploy --prod --dir build/html
31 changes: 31 additions & 0 deletions _redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/ /latest/ 302
/latest/* /2.2/:splat 301
/:version/* /:version/ca/:splat 301 Language=ca
/:version/* /:version/cs/:splat 301 Language=cs
/:version/* /:version/de-DE/:splat 301 Language=de-DE
/:version/* /:version/de/:splat 301 Language=de
/:version/* /:version/en-GB/:splat 301 Language=en-GB
/:version/* /:version/es-ES/:splat 301 Language=es-ES
/:version/* /:version/es-MX/:splat 301 Language=es-MX
/:version/* /:version/es/:splat 301 Language=es
/:version/* /:version/fi/:splat 301 Language=fi
/:version/* /:version/fr/:splat 301 Language=fr
/:version/* /:version/gl/:splat 301 Language=gl
/:version/* /:version/id/:splat 301 Language=id
/:version/* /:version/it/:splat 301 Language=it
/:version/* /:version/ja-JP/:splat 301 Language=ja-JP
/:version/* /:version/kn/:splat 301 Language=kn
/:version/* /:version/nl/:splat 301 Language=nl
/:version/* /:version/pl/:splat 301 Language=pl
/:version/* /:version/pt-BR/:splat 301 Language=pt-BR
/:version/* /:version/pt/:splat 301 Language=pt
/:version/* /:version/ro/:splat 301 Language=ro
/:version/* /:version/ru-RU/:splat 301 Language=ru-RU
/:version/* /:version/ru/:splat 301 Language=ru
/:version/* /:version/sl/:splat 301 Language=sl
/:version/* /:version/sq/:splat 301 Language=sq
/:version/* /:version/sr/:splat 301 Language=sr
/:version/* /:version/tr/:splat 301 Language=tr
/:version/* /:version/zh-CN/:splat 301 Language=zh-CN
/:version/* /:version/zh-TW/:splat 301 Language=zh-TW
/:version/* /:version/en/:splat 301
34 changes: 34 additions & 0 deletions build_manual.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
# Parse languages and ensure that "en" is built last
cd source || exit 1
LANGUAGES="$(python -c 'import conf; print(" ".join(sorted((lang for lang in conf.supported_languages.keys() if lang != "en"), reverse=True)))')"
cd .. || exit 1
LANGUAGES="$LANGUAGES en"
NUM_LANGUAGES="$(printf '%s' "$LANGUAGES" | wc -w)"

# Write _redirects file
mkdir -p build/html
printf '/ /latest/ 302\n' > build/html/_redirects
printf '/latest/* /2.2/:splat 301\n' >> build/html/_redirects

i=1
for lang in $LANGUAGES
do
printf -- '----- Building language "%s"... [%d/%d] -----\n' "$lang" "$i" "$NUM_LANGUAGES"

if [ "$lang" = "en" ]
then
printf '/:version/* /:version/en/:splat 301\n' >> build/html/_redirects
else
printf '/:version/* /:version/%s/:splat 301 Language=%s\n' "$lang" "$lang" >> build/html/_redirects
fi
make versionedhtml SPHINXOPTS="-Q -j $(nproc) -Dlanguage=$lang"
make versionedlatexpdf SPHINXOPTS="-Q -j $(nproc) -Dlanguage=$lang" >/dev/null
i=$((i + 1))
done

cd build/latex || exit 1
for file in */*/Mixxx-Manual.pdf
do
cp "$file" "../html/$file"
done
20 changes: 20 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Settings in the [build] context are global and are applied to all contexts
# unless otherwise overridden by more specific contexts.
[build]
# Directory to change to before starting a build.
# This is where we will look for package.json/.nvmrc/etc.
base = ""

# Default build command.
command = "sphinx-build -b html source build"

# Directory (relative to root of your repo) that contains the deploy-ready
# HTML files and assets generated by the build. If a base directory has
# been specified, include it in the publish directory path.
publish = "build"

[context.production]
# Production content is pushed to master
# Exit code 0 means that this build will be ignored
# https://docs.netlify.com/configure-builds/file-based-configuration/#ignore-builds
ignore = "true"
1 change: 1 addition & 0 deletions runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.7