-
-
Notifications
You must be signed in to change notification settings - Fork 18
55 lines (52 loc) · 1.5 KB
/
publish.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
# This workflow is triggered two ways:
#
# 1. When a tag is created, the workflow will upload the package to
# test.pypi.org.
# 2. When a release is made, the workflow will upload the package to pypi.org.
#
# It is done this way until PyPI has draft reviews, to allow for a two-stage
# upload with a chance for manual intervention before the final publication.
name: Upload package
on:
release:
types: [created]
push:
tags:
- '*'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U tox
- name: Create tox environments
run: |
tox -p -e py,build,release --notest
- name: Run tests
run: |
tox -e py
- name: Build package
run: |
tox -e build
- name: Publish package
env:
TWINE_USERNAME: "__token__"
run: |
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
export TWINE_REPOSITORY_URL="https://test.pypi.org/legacy/"
export TWINE_PASSWORD="${{ secrets.TEST_PYPI_UPLOAD_TOKEN }}"
elif [[ "$GITHUB_EVENT_NAME" == "release" ]]; then
export TWINE_REPOSITORY="pypi"
export TWINE_PASSWORD="${{ secrets.PYPI_UPLOAD_TOKEN }}"
else
echo "Unknown event name: ${GITHUB_EVENT_NAME}"
exit 1
fi
tox -e release