-
Notifications
You must be signed in to change notification settings - Fork 7
162 lines (152 loc) Β· 5.08 KB
/
pythonpackage.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
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
154
155
156
157
158
159
160
161
162
name: Python package
on: [push, pull_request, workflow_dispatch]
env:
release-python-version: "3.10"
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Protoc
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[typing,lint,test,pandas]
- name: Lint with flake8
run: |
flake8 .
- name: Test with pytest
run: |
pytest
- name: Format using black
run: |
black --check .
- name: Sort imports with isort
run: |
isort --diff --check .
- name: Build protobuf files
run: python setup.py build_protobuf
- name: Run mypy
run: |
mypy --strict metricq examples tests setup.py
build:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.release-python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.release-python-version }}
- name: Install Protoc
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Build Python distribution
run: pip wheel --wheel-dir dist/ .
- name: Upload distribution artifacts
uses: actions/upload-artifact@v4
with:
name: distribution-packages
path: dist/metricq-*.whl
release:
needs: [build]
runs-on: ubuntu-latest
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: Download distribution artifacts
uses: actions/download-artifact@v4
with:
name: distribution-packages
path: dist/
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
- name: Reformat version number
id: reformat_release
uses: frabert/replace-string-action@v1.1
with:
pattern: 'refs\/tags\/v([0-9.]+)'
string: ${{ github.ref }}
replace-with: "$1"
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get last tag
id: get_last_tag
run: echo "::set-output name=last_tag::$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))"
- name: Generate release changelog
uses: charmixer/auto-changelog-action@v1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
since_tag: ${{ steps.get_last_tag.outputs.last_tag }}
base: "none.md" # ignore the HISTORY.md file
output: release-changelog.md
- name: Upload release changelog artifact
uses: actions/upload-artifact@v4
with:
name: release-changelog
path: release-changelog.md
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Python Release ${{ steps.reformat_release.outputs.replaced }}
draft: false
prerelease: false
body_path: release-changelog.md
docs:
needs: [build]
runs-on: ubuntu-latest
env:
OUTPUT_DIR: build/sphinx
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.release-python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.release-python-version }}
- name: Install Protoc
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
- name: Install pip
run: |
python -m pip install --upgrade pip
- name: Install dependencies
run: |
pip install '.[docs]'
- name: Build documentation
run: |
# run HTML builder (-b) in nitpicky mode (-n) in a fresh environment (-E)
sphinx-build -b html -n -E docs ${{ env.OUTPUT_DIR }}
- name: Upload generated HTML as build artifact
uses: actions/upload-artifact@v4
with:
path: ${{ env.OUTPUT_DIR }}
name: docs
- name: Deploy documentation to GitHub Pages
uses: JamesIves/github-pages-deploy-action@3.7.1
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
with:
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: ${{ env.OUTPUT_DIR }}