2020-02-10 14:34:58 +03:00
|
|
|
# Copyright (c) 2016-2020 Martin Donath <martin.donath@squidfunk.com>
|
2019-12-06 17:52:21 +03:00
|
|
|
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to
|
|
|
|
# deal in the Software without restriction, including without limitation the
|
|
|
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
# sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
# IN THE SOFTWARE.
|
|
|
|
|
2019-12-08 19:09:45 +03:00
|
|
|
name: ci
|
2019-12-06 17:52:21 +03:00
|
|
|
on:
|
|
|
|
- push
|
|
|
|
- pull_request
|
|
|
|
|
2020-04-17 11:01:36 +03:00
|
|
|
env:
|
|
|
|
CI: true
|
|
|
|
NODE_VERSION: 10.x
|
|
|
|
PYTHON_VERSION: 3.x
|
|
|
|
|
2019-12-06 17:52:21 +03:00
|
|
|
# Jobs to run
|
|
|
|
jobs:
|
|
|
|
|
|
|
|
# Build theme
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
|
2020-03-06 16:50:26 +03:00
|
|
|
# Checkout source form GitHub
|
2020-03-06 12:31:56 +03:00
|
|
|
- uses: actions/checkout@v2
|
2019-12-06 17:52:21 +03:00
|
|
|
|
|
|
|
# Install Node runtime and dependencies
|
|
|
|
- uses: actions/setup-node@v1
|
|
|
|
with:
|
2020-04-17 11:01:36 +03:00
|
|
|
node-version: ${{ env.NODE_VERSION }}
|
2019-12-06 17:52:21 +03:00
|
|
|
|
|
|
|
- uses: actions/cache@v1
|
|
|
|
id: cache-node
|
|
|
|
with:
|
|
|
|
path: node_modules
|
2020-04-17 11:01:36 +03:00
|
|
|
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
|
2019-12-06 17:52:21 +03:00
|
|
|
|
|
|
|
- if: steps.cache-node.outputs.cache-hit != 'true'
|
|
|
|
run: npm install
|
|
|
|
|
2020-03-06 16:50:26 +03:00
|
|
|
# Run linter
|
2019-12-06 17:52:21 +03:00
|
|
|
- run: npm run lint
|
2020-03-06 16:50:26 +03:00
|
|
|
|
|
|
|
# Build distribution files
|
2019-12-06 17:52:21 +03:00
|
|
|
- run: npm run build
|
|
|
|
|
2019-12-25 17:09:36 +03:00
|
|
|
# Check diff after build
|
|
|
|
- run: git diff --name-only
|
|
|
|
|
2019-12-06 17:52:21 +03:00
|
|
|
# Build and deploy documentation site
|
|
|
|
deploy:
|
|
|
|
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
|
2020-03-06 16:50:26 +03:00
|
|
|
# Checkout source form GitHub
|
2020-03-06 12:31:56 +03:00
|
|
|
- uses: actions/checkout@v2
|
2019-12-06 17:52:21 +03:00
|
|
|
|
|
|
|
# Install Python runtime and dependencies
|
|
|
|
- uses: actions/setup-python@v1
|
|
|
|
with:
|
2020-04-17 11:01:36 +03:00
|
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
2019-12-06 17:52:21 +03:00
|
|
|
|
2020-02-15 13:13:22 +03:00
|
|
|
# - uses: actions/cache@v1
|
|
|
|
# id: cache-python
|
|
|
|
# with:
|
|
|
|
# path: ~/.cache/pip
|
2020-04-17 11:01:36 +03:00
|
|
|
# key: ${{ runner.os }}-pip-${{ env.PYTHON_VERSION }}-${{ hashFiles('**/requirements.txt') }}
|
2019-12-06 17:52:21 +03:00
|
|
|
|
2020-02-15 13:13:22 +03:00
|
|
|
# - if: steps.cache-python.outputs.cache-hit != 'true'
|
|
|
|
- run: pip install -r requirements.txt
|
2019-12-06 17:52:21 +03:00
|
|
|
|
|
|
|
# Set configuration for repository and deploy documentation
|
|
|
|
- env:
|
|
|
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
|
|
GH_NAME: ${{ secrets.GH_NAME }}
|
|
|
|
GH_EMAIL: ${{ secrets.GH_EMAIL }}
|
|
|
|
run: |
|
2020-03-09 18:54:26 +03:00
|
|
|
REMOTE="https://${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}"
|
2019-12-06 17:52:21 +03:00
|
|
|
git config --global user.name "${GH_NAME}"
|
|
|
|
git config --global user.email "${GH_EMAIL}"
|
|
|
|
git remote set-url origin ${REMOTE}
|
|
|
|
|
2020-02-14 11:31:59 +03:00
|
|
|
# Install theme and dependencies
|
|
|
|
- run: |
|
2020-03-15 17:30:56 +03:00
|
|
|
pip install .
|
2020-02-14 11:31:59 +03:00
|
|
|
pip install mkdocs-minify-plugin>=0.2
|
2019-12-06 17:52:21 +03:00
|
|
|
|
|
|
|
# Build documentation
|
2019-12-07 19:23:57 +03:00
|
|
|
- env:
|
|
|
|
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
|
|
|
|
run: |
|
2019-12-06 17:52:21 +03:00
|
|
|
mkdocs gh-deploy --force
|
|
|
|
mkdocs --version
|
|
|
|
|
2020-02-17 19:25:40 +03:00
|
|
|
# Publish Python package and Docker image
|
|
|
|
publish:
|
2020-02-25 01:07:14 +03:00
|
|
|
if: |
|
2020-02-25 13:32:54 +03:00
|
|
|
github.repository == 'squidfunk/mkdocs-material' &&
|
2020-02-25 01:07:14 +03:00
|
|
|
startsWith(github.ref, 'refs/tags')
|
2020-02-17 19:25:40 +03:00
|
|
|
needs: build
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
|
2020-03-06 16:50:26 +03:00
|
|
|
# Checkout source form GitHub
|
2020-03-06 12:31:56 +03:00
|
|
|
- uses: actions/checkout@v2
|
2020-02-17 19:25:40 +03:00
|
|
|
|
2020-03-06 12:31:56 +03:00
|
|
|
# Install Node runtime and dependencies
|
|
|
|
- uses: actions/setup-node@v1
|
|
|
|
with:
|
2020-04-17 11:01:36 +03:00
|
|
|
node-version: ${{ env.NODE_VERSION }}
|
2020-02-17 19:25:40 +03:00
|
|
|
|
2020-03-06 12:31:56 +03:00
|
|
|
- uses: actions/cache@v1
|
|
|
|
id: cache-node
|
2020-02-17 19:25:40 +03:00
|
|
|
with:
|
2020-03-06 12:31:56 +03:00
|
|
|
path: node_modules
|
2020-04-17 11:01:36 +03:00
|
|
|
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
|
2020-03-06 12:31:56 +03:00
|
|
|
|
|
|
|
- if: steps.cache-node.outputs.cache-hit != 'true'
|
|
|
|
run: npm install
|
|
|
|
|
|
|
|
# Build distribution files
|
|
|
|
- run: npm run build
|
2020-02-17 19:25:40 +03:00
|
|
|
|
|
|
|
# Install Python runtime and dependencies
|
|
|
|
- uses: actions/setup-python@v1
|
|
|
|
with:
|
2020-04-17 11:01:36 +03:00
|
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
2020-02-17 19:25:40 +03:00
|
|
|
|
|
|
|
- run: pip install --upgrade setuptools wheel twine
|
|
|
|
|
2020-04-07 18:00:14 +03:00
|
|
|
# Build and test Docker image
|
|
|
|
- run: |
|
|
|
|
docker build -t ${GITHUB_REPOSITORY} .
|
2020-04-07 18:20:25 +03:00
|
|
|
docker run --rm -i -v $(pwd):/docs ${GITHUB_REPOSITORY} build
|
2020-02-17 19:25:40 +03:00
|
|
|
|
|
|
|
# Build Python package
|
|
|
|
- run: python setup.py build sdist bdist_wheel --universal
|
|
|
|
|
2020-03-06 16:50:26 +03:00
|
|
|
# Push package to PyPI
|
2020-02-17 19:25:40 +03:00
|
|
|
- env:
|
|
|
|
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
|
|
|
|
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
|
|
|
|
run: twine upload -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} dist/*
|
|
|
|
|
2020-04-07 18:00:14 +03:00
|
|
|
# Push image to Docker Hub
|
|
|
|
- env:
|
|
|
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
run: |
|
|
|
|
docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
|
|
|
|
docker tag ${GITHUB_REPOSITORY} ${GITHUB_REPOSITORY}:${GITHUB_REF##*/}
|
|
|
|
docker tag ${GITHUB_REPOSITORY} ${GITHUB_REPOSITORY}:latest
|
|
|
|
docker push ${GITHUB_REPOSITORY}
|