-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (63 loc) · 2.24 KB
/
upload-to-pypi.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
name: Upload to PyPI
on:
push:
tags:
- v*
jobs:
check_version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version_in_branch.outputs.version_in_branch }}
version_matched: ${{ steps.compare_version.outputs.matched }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Extract richcat version from branch name
id: get_version_in_branch
run: echo "::set-output name=version_in_branch::$(echo ${GITHUB_REF#refs/tags/} | sed 's/v//')"
- name: Get richcat version from code
id: get_version_in_code
run: echo "::set-output name=version_in_code::$(python ./scripts/get_version.py)"
- name: Compare version
id: compare_version
run: echo "::set-output name=matched::$([[ ${{ steps.get_version_in_branch.outputs.version_in_branch }} == ${{ steps.get_version_in_code.outputs.version_in_code }} ]]; echo $?)"
release_richcat:
runs-on: ubuntu-latest
needs: check_version
if: ${{ needs.check_version.outputs.version_matched == 0 }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install wheel twine
- name: Build
run: |
rm -rf ./richcat.egg-info/ dist/
python setup.py bdist_wheel
- name: Publish package to PyPI
id: upload
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Create release
if: steps.upload.conclusion == 'success'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.check_version.outputs.version }}
release_name: Release v${{ needs.check_version.outputs.version }}
draft: false
prerelease: false