-
Notifications
You must be signed in to change notification settings - Fork 261
78 lines (67 loc) · 2.05 KB
/
build-n-publish-to-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
70
71
72
73
74
75
76
77
78
# link: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
name: publish 📦 to PyPI
# Build on every branch push, tag push, and pull request change
on:
push:
branches:
- main
tags:
- v*
pull_request:
jobs:
build-sdist-n-wheel:
name: Build 🐍 distributions and wheels 📦
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a source tarball and a binary wheel
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- uses: actions/upload-artifact@v4
with:
path: |
dist/*.tar.gz
dist/*.whl
upload-to-pypi:
name: Upload 📦 to (Test) PyPI
needs: [build-sdist-n-wheel]
runs-on: ubuntu-latest
if: github.repository_owner == 'insarlab' && github.event_name == 'push'
steps:
- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist
- name: Publish developed version 📦 to Test PyPI
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: false
verbose: true
- name: Publish released version 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true