-
Notifications
You must be signed in to change notification settings - Fork 4
46 lines (44 loc) · 1.26 KB
/
build-and-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
name: publish
on:
release:
types: [published]
branches:
- master
jobs:
publish:
name: Publish 🚀
runs-on: ubuntu-latest
env:
VERSION: null
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 build
- name: Get version
run: |
cat setup.cfg | grep "version = " | awk '{print "VERSION="$(NF)}' >> $GITHUB_ENV
- name: Build a binary wheel and a source tarball 🚧
run: python -m build --sdist --wheel --outdir dist/ .
- name: Validate release tag
run: |
if [ "${GITHUB_REF#refs/tags/}" != "${VERSION}" ]; then exit 1; fi
- name: Publish to Test PyPI 📦
if: contains(env.VERSION, 'a')
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish to PyPI 📦
if: |
!contains(env.VERSION, 'a')
uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}