-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (75 loc) · 3.6 KB
/
publish-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
79
80
name: Publish Release to PyPi
on:
release:
types: [published]
jobs:
build_and_publish:
runs-on: ubuntu-latest
environment: post-release
steps:
- name: Generate Upload URL
id: gen-upload-url
run: |
sudo apt-get install jq;
RELEASE_ID=$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH);
RELEASE_BODY=$(jq --raw-output '.release.body' $GITHUB_EVENT_PATH);
echo ::set-output name=upload-url::https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets
echo ::set-output name=release-body::${RELEASE_BODY}
- uses: actions/[email protected]
name: Checkout
- name: Setup python 2
uses: actions/setup-python@v2
with:
python-version: 2.7
architecture: x64
- name: Pip2 install
run: pip2 install setuptools wheel twine
- name: Setup python 3
uses: actions/setup-python@v2
with:
python-version: 3.x
architecture: x64
- name: Pip3 install
run: pip3 install setuptools wheel twine
- name: Build Wheels
id: build-wheel
run: |
# Build Python2
python2 setup.py sdist bdist_wheel
# Build Python3
python3 setup.py sdist bdist_wheel
cd ${GITHUB_WORKSPACE}/dist
echo ::set-output name=asset-name-py2::$(ls *py2*.whl | tr '\r\n' ' ')
echo ::set-output name=asset-name-py3::$(ls *py3*.whl | tr '\r\n' ' ')
echo ::set-output name=asset-path-py2::${GITHUB_WORKSPACE}/dist/$(ls *py2*.whl | tr '\r\n' ' ')
echo ::set-output name=asset-path-py3::${GITHUB_WORKSPACE}/dist/$(ls *py3*.whl | tr '\r\n' ' ')
- name: Publish to PyPi
run: |
echo "----------------------------"
echo "Checking: $(ls dist/*.whl | tr '\r\n' ' ')"
twine check --strict dist/*.whl
echo "----------------------------"
echo "Uploading: $(ls dist/*.whl | tr '\r\n' ' ')"
twine upload dist/*.whl --verbose --skip-existing
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
TWINE_NON_INTERACTIVE: 1
- name: Upload Python 2 Wheel To Github
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.gen-upload-url.outputs.upload-url }}?name=${{ steps.build-wheel.outputs.asset-name-py2 }}
asset_path: ${{ steps.build-wheel.outputs.asset-path-py2 }}
asset_name: ${{ steps.build-wheel.outputs.asset-name-py2 }}
asset_content_type: application/x-wheel+zip
- name: Upload Python 3 Wheel To Github
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.gen-upload-url.outputs.upload-url }}?name=${{ steps.build-wheel.outputs.asset-name-py3 }}
asset_path: ${{ steps.build-wheel.outputs.asset-path-py3 }}
asset_name: ${{ steps.build-wheel.outputs.asset-name-py3 }}
asset_content_type: application/x-wheel+zip