1+ name : test_deploy
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ tags : [ '*' ]
7+ pull_request :
8+ branches : [ main ]
9+
10+ env :
11+ PYTHON_VERSION : " {{cookiecutter.python_version}}"
12+
13+ jobs :
14+ test :
15+ runs-on : ubuntu-latest
16+
17+ steps :
18+ - name : Checkout repository
19+ uses : actions/checkout@v4
20+
21+ - name : Setup Python and install dependencies
22+ uses : ./.github/actions/setup
23+ with :
24+ python-version : ${{ env.PYTHON_VERSION }}
25+ dependencies : dev
26+
27+ - name : Run tests
28+ run : pytest
29+
30+ {% if cookiecutter.include_docs == 'y' %}
31+ deploy-docs :
32+ runs-on : ubuntu-latest
33+
34+ # Do not run on git tag (i.e. releases).
35+ # Only runs if tests pass.
36+ if : ${{ !startsWith(github.ref, 'refs/tags/') }}
37+ needs : [test]
38+
39+ steps :
40+ - name : Checkout repository
41+ uses : actions/checkout@v4
42+
43+ - name : Setup Python and install dependencies
44+ uses : ./.github/actions/setup
45+ with :
46+ python-version : ${{ env.PYTHON_VERSION }}
47+ dependencies : docs
48+
49+ - name : Build documentation
50+ run : |
51+ cp README.md docs/index.md
52+ cp CHANGELOG.md docs/changelog.md
53+ # --strict errors on any warnings.
54+ # builds the site to ./site.
55+ mkdocs build --strict
56+
57+ - name : Deploy to GitHub Pages
58+ # Only trigger on push to main branch.
59+ if : github.ref == 'refs/heads/main' && github.event_name == 'push'
60+ uses : peaceiris/actions-gh-pages@v4
61+ with :
62+ github_token : ${{ secrets.GITHUB_TOKEN }}
63+ publish_dir : ./site
64+ {% endif %}
65+
66+ {% if cookiecutter.include_pypi == 'y' %}
67+ deploy-pypi :
68+ runs-on : ubuntu-latest
69+
70+ # Only runs on git tag and if tests pass.
71+ if : startsWith(github.ref, 'refs/tags/')
72+ needs : [test]
73+
74+ # Authenticate for PyPI publishing.
75+ permissions :
76+ id-token : write
77+
78+ steps :
79+ - name : Checkout repository
80+ uses : actions/checkout@v4
81+
82+ - name : Setup Python and install dependencies
83+ uses : ./.github/actions/setup
84+ with :
85+ python-version : ${{ env.PYTHON_VERSION }}
86+ dependencies : build
87+
88+ - name : Build package
89+ run : python -m build
90+
91+ - name : Publish to PyPI
92+ uses : pypa/gh-action-pypi-publish@release/v1
93+ {% endif %}
0 commit comments