-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (82 loc) · 2.82 KB
/
workflow.yml
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: workflow
on:
push:
branches: [main, master]
tags: ["v*"]
pull_request:
branches: [main, master]
jobs:
get-version-pep440:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Get PEP-440 style version
id: get-version
run: |
PEP440_VERSION=""
VERSION_PREFIX="v"
BRANCH_OR_TAG="$(echo ${{ github.event.ref }} | cut -d / -f 3)"
if [[ "${BRANCH_OR_TAG}" =~ ^v?(([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*(\.?(a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?)$ ]]
then
PEP440_VERSION="${BRANCH_OR_TAG#$VERSION_PREFIX}"
fi
echo "version=${PEP440_VERSION}" | tee -a $GITHUB_OUTPUT
check-mkdocs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip # caching pip dependencies
- name: Install project and dependent tools
run: |
python -m pip install -e . -r requirements.txt
- name: Check with ruff
run: |
python -m ruff check .
- name: MkDocs gh-deploy --force
uses: mhausenblas/mkdocs-deploy-gh-pages@master
env:
CONFIG_FILE: mkdocs.yml
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
needs: [get-version-pep440, check-mkdocs]
if: needs.get-version-pep440.outputs.version != ''
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip" # caching pip dependencies
- name: Install builder
run: pip install build
- name: Build Python distribution
run: python -m build
- name: Upload dist to artifact
uses: actions/upload-artifact@v4
with:
name: mkdocs_nbconvert-dist-${{ needs.get-version-pep440.outputs.version }}
path: dist
if-no-files-found: error
retention-days: 1
publish:
runs-on: ubuntu-latest
needs: [get-version-pep440, build]
if: needs.get-version-pep440.outputs.version != ''
steps:
- name: Download dist from artifact
uses: actions/download-artifact@v4
with:
name: mkdocs_nbconvert-dist-${{needs.get-version-pep440.outputs.version}}
path: dist
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1