1
+ name : Publish 🐍 distributions 📦 to PyPI
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - master
7
+ jobs :
8
+ build-and-publish :
9
+ name : Build and publish 🐍 distributions 📦 to PyPI
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Check out repository code
13
+ uses : actions/checkout@v2
14
+
15
+ - name : Fetch version
16
+ run : |
17
+ output="$(python setup.py --version)"
18
+ echo "::set-output name=version::$output"
19
+ id : setup_version
20
+ - name : Print build version
21
+ run : echo "${{ steps.setup_version.outputs.version }}"
22
+
23
+ # Setup Python (faster than using Python container)
24
+ - name : Setup Python
25
+ uses : actions/setup-python@v2
26
+ with :
27
+ python-version : " 3.7"
28
+
29
+ - name : Install pipenv
30
+ run : |
31
+ python -m pip install --upgrade pipenv wheel
32
+ - id : cache-pipenv
33
+ uses : actions/cache@v1
34
+ with :
35
+ path : ~/.local/share/virtualenvs
36
+ key : ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
37
+
38
+ - name : Install dependencies
39
+ if : steps.cache-pipenv.outputs.cache-hit != 'true'
40
+ run : |
41
+ pipenv install --deploy --dev
42
+
43
+ - name : Build a binary wheel and a source tarball
44
+ run : |
45
+ pipenv run build
46
+ # git tag created using version specified in setup.py
47
+ - name : Bump git tag version
48
+ id : tag_version
49
+ uses :
mathieudutour/[email protected]
50
+ with :
51
+ github_token : ${{ secrets.GITHUB_TOKEN }}
52
+ custom_tag : ${{ steps.setup_version.outputs.version }}
53
+ - name : Create a GitHub release
54
+ uses : ncipollo/release-action@v1
55
+ with :
56
+ tag : ${{ steps.tag_version.outputs.new_tag }}
57
+ name : Release ${{ steps.tag_version.outputs.new_tag }}
58
+ body : ${{ github.event.head_commit.message }}
59
+
60
+ - name : Publish distribution 📦 to Test PyPI
61
+ uses : pypa/gh-action-pypi-publish@master
62
+ with :
63
+ password : ${{ secrets.TEST_PYPI_API_TOKEN }}
64
+ repository_url : https://test.pypi.org/legacy/
65
+ verbose : true
66
+ skip_existing : true
67
+
68
+ - name : Publish distribution 📦 to PyPI
69
+ uses : pypa/gh-action-pypi-publish@master
70
+ with :
71
+ password : ${{ secrets.PYPI_API_TOKEN }}
72
+ verbose : true
0 commit comments