File tree Expand file tree Collapse file tree 2 files changed +71
-0
lines changed
Expand file tree Collapse file tree 2 files changed +71
-0
lines changed Original file line number Diff line number Diff line change 1+ # This workflow is triggered two ways:
2+ #
3+ # 1. When a tag is created, the workflow will upload the package to
4+ # test.pypi.org.
5+ # 2. When a release is made, the workflow will upload the package to pypi.org.
6+ #
7+ # It is done this way until PyPI has draft reviews, to allow for a two-stage
8+ # upload with a chance for manual intervention before the final publication.
9+ name : Upload package
10+
11+ on :
12+ release :
13+ types : [created]
14+ push :
15+ tags :
16+ - ' *'
17+
18+ jobs :
19+ deploy :
20+ runs-on : ubuntu-latest
21+ steps :
22+ - uses : actions/checkout@v2
23+ - name : Set up Python
24+ uses : actions/setup-python@v2
25+ with :
26+ python-version : ' 3.x'
27+ - name : Install dependencies
28+ run : |
29+ python -m pip install --upgrade pip
30+ pip install -U tox
31+ - name : Create tox environments
32+ run : |
33+ tox -p -e py,build,release --notest
34+ - name : Run tests
35+ run : |
36+ tox -e py
37+ - name : Build package
38+ run : |
39+ tox -e build
40+ - name : Publish package
41+ env :
42+ TWINE_USERNAME : " __token__"
43+ run : |
44+ if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
45+ export TWINE_REPOSITORY_URL="https://test.pypi.org/legacy/"
46+ export TWINE_PASSWORD="${{ secrets.TEST_PYPI_UPLOAD_TOKEN }}"
47+ elif [[ "$GITHUB_EVENT_NAME" == "release" ]]; then
48+ export TWINE_REPOSITORY="pypi"
49+ export TWINE_PASSWORD="${{ secrets.PYPI_UPLOAD_TOKEN }}"
50+ else
51+ echo "Unknown event name: ${GITHUB_EVENT_NAME}"
52+ exit 1
53+ fi
54+
55+ tox -e release
Original file line number Diff line number Diff line change @@ -48,5 +48,21 @@ deps =
4848 pep517
4949 twine
5050commands =
51+ python -c " from pathlib import Path; \
52+ [x.unlink(missing_ok=True) for x in Path('{toxinidir}/dist').glob('*')]"
5153 python -m pep517.build -s -b {toxinidir} -o {toxinidir}/dist
5254 twine check {toxinidir}/dist/*
55+
56+ [testenv:release]
57+ description = Make a release; must be called after "build"
58+ skip_install = True
59+ deps =
60+ twine
61+ depends =
62+ build
63+ passenv =
64+ TWINE_*
65+ commands =
66+ twine check {toxinidir}/dist/*
67+ twine upload {toxinidir}/dist/* \
68+ {posargs:-r testpypi --non-interactive}
You can’t perform that action at this time.
0 commit comments