-
Notifications
You must be signed in to change notification settings - Fork 8
69 lines (57 loc) · 2.09 KB
/
publish-to-test-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
on:
push:
branches: [ master ]
release:
types:
- published
name: Publish Python distributions to PyPI
jobs:
get_commit_message:
name: Get commit message
runs-on: ubuntu-latest
outputs:
message: ${{ steps.commit_message.outputs.message }}
steps:
- name: Checkout the repo
uses: actions/checkout@v3
# Gets the correct commit message for pull request
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Get commit message
id: commit_message
run: |
set -xe
COMMIT_MSG=$(git log --no-merges -1 --oneline)
echo "::set-output name=message::$COMMIT_MSG"
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
needs: get_commit_message
# The Python package will be published to PyPI only if commit contains
# [pypi release] trigger in its message or if there is a release on GitHub.
# NOTE: do not forget to update the `version` parameter in `setup.cfg` before pushing !
if: >-
contains(needs.get_commit_message.outputs.message, '[pypi release]') ||
github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install PyPA build and setuptools
run: python -m pip install -U setuptools build --user
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
- name: List all produced packages and wheels
run: ls -sh -w 1
working-directory: dist
#- name: Publish distribution 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}