-
Notifications
You must be signed in to change notification settings - Fork 3
executable file
·153 lines (122 loc) · 4.61 KB
/
ci.yml
File metadata and controls
executable file
·153 lines (122 loc) · 4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Copyright (c) 2016-2020 Martin Donath <martin.donath@squidfunk.com>
# 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.
name: ci
on:
- push
- pull_request
# Environment
env:
CI: true
NODE_VERSION: 10.x
PYTHON_VERSION: 3.x
# Jobs to run
jobs:
# Build theme
build:
runs-on: ubuntu-latest
steps:
# Checkout source form GitHub
- uses: actions/checkout@v2
# Install Node runtime and dependencies
- uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v1
id: cache-node
with:
path: node_modules
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
- if: steps.cache-node.outputs.cache-hit != 'true'
run: npm install
# Run linter
- run: npm run lint
# Build distribution files
- run: npm run build
# Check diff after build
- run: git diff --name-only
# Build and deploy documentation site
deploy:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
# Checkout source form GitHub
- uses: actions/checkout@v2
# Install Python runtime and dependencies
- uses: actions/setup-python@v1
with:
python-version: ${{ env.PYTHON_VERSION }}
# Install theme and dependencies
- run: |
pip install -r requirements.txt
pip install .
pip install \
mkdocs-minify-plugin>=0.3 \
mkdocs-redirects>=1.0
# Build documentation
- env:
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
run: |
mkdocs gh-deploy --force
mkdocs --version
# Publish Python package and Docker image
publish:
if: |
github.repository == 'squidfunk/mkdocs-material' &&
startsWith(github.ref, 'refs/tags')
needs: build
runs-on: ubuntu-latest
steps:
# Checkout source form GitHub
- uses: actions/checkout@v2
# Install Node runtime and dependencies
- uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: actions/cache@v1
id: cache-node
with:
path: node_modules
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
- if: steps.cache-node.outputs.cache-hit != 'true'
run: npm install
# Build distribution files
- run: npm run build
# Install Python runtime and dependencies
- uses: actions/setup-python@v1
with:
python-version: ${{ env.PYTHON_VERSION }}
- run: pip install --upgrade setuptools wheel twine
# Build and test Docker image
- run: |
docker build -t ${GITHUB_REPOSITORY} .
docker run --rm -i -v $(pwd):/docs ${GITHUB_REPOSITORY} build
# Build Python package
- run: python setup.py build sdist bdist_wheel --universal
# Push package to PyPI
- env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} dist/*
# 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}