Skip to content

Commit 69260de

Browse files
authored
Create build-pypi.yml
1 parent 8cc120f commit 69260de

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

Diff for: .github/workflows/build-pypi.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: build python package and upload to pypi
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
testing:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: '3.8'
16+
- name: install standard python dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install flake8 pytest
20+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
21+
if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi
22+
- name: Lint with flake8
23+
run: |
24+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
25+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
26+
- name: test with pytest
27+
run: pytest
28+
29+
build:
30+
runs-on: ubuntu-latest
31+
needs: testing
32+
steps:
33+
- uses: actions/checkout@v2
34+
- name: Set up Python
35+
uses: actions/setup-python@v2
36+
with:
37+
python-version: '3.8'
38+
- name: install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
python -m pip install setuptools wheel twine build
42+
pip install -r requirements.txt
43+
- name: get version
44+
id: get_version
45+
run: |
46+
echo -e "import ${{ github.event.repository.name }}\nprint(${{ github.event.repository.name }}.__version__)" >> get_version.py
47+
echo ::set-output name=VERSION::"$(python get_version.py)"
48+
- name: build package
49+
run: |
50+
python setup.py sdist bdist_wheel
51+
- name: release
52+
uses: marvinpinto/action-automatic-releases@latest
53+
id: create_release
54+
with:
55+
draft: false
56+
prerelease: false
57+
automatic_release_tag: v${{ steps.get_version.outputs.VERSION }}
58+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
59+
title: v${{ steps.get_version.outputs.VERSION }}
60+
files: dist/*
61+
- name: save dist for upload
62+
uses: actions/upload-artifact@v2
63+
with:
64+
name: dist
65+
path: dist
66+
upload:
67+
runs-on: ubuntu-latest
68+
needs: build
69+
steps:
70+
- uses: actions/checkout@v2
71+
- uses: actions/download-artifact@v2
72+
with:
73+
name: dist
74+
path: dist
75+
- name: Publish a Python distribution to PyPI
76+
uses: pypa/gh-action-pypi-publish@release/v1
77+
with:
78+
user: __token__
79+
password: ${{ secrets.PYPI_API_TOKEN }}
80+

0 commit comments

Comments
 (0)