-
Notifications
You must be signed in to change notification settings - Fork 3
51 lines (44 loc) · 1.51 KB
/
upload-to-pip.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
name: Upload to PIP
on:
# Triggers the workflow when a release is created
release:
types: [created]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
upload:
runs-on: ubuntu-latest
steps:
# Checks-out repository under $GITHUB_WORKSPACE
- name: "Checkout repository and submodules"
uses: actions/checkout@v2
with:
submodules: recursive
# Set up python
- uses: actions/setup-python@v2
with:
python-version: 3.8
# Set package version number
- name: Set version number to release number
run: |
VERSION=${{github.event.release.tag_name}}
PLACEHOLDER='version="main"'
VERSION_FILE='setup.py'
# ensure the placeholder is there. If grep doesn't find the placeholder
# it exits with exit code 1 and github actions aborts the build.
grep "$PLACEHOLDER" "$VERSION_FILE"
sed -i "s/$PLACEHOLDER/version = \"${VERSION}\"/g" "$VERSION_FILE"
shell: bash
# Install dependencies
- name: "Install dependencies"
run: |
python3 -m pip install --upgrade pip
python3 -m pip install setuptools wheel twine
# Build and upload to PyPI
- name: "Build and upload to PyPI"
run: |
python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/* --verbose
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }}