-
Notifications
You must be signed in to change notification settings - Fork 6
60 lines (53 loc) · 1.89 KB
/
deploy.yml
File metadata and controls
60 lines (53 loc) · 1.89 KB
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Deploy to PyPi
# run on merge to master or manual trigger
on:
push:
paths:
- 'src/**/*'
- 'setup.py'
- 'requirements.txt'
branches:
- 'main'
workflow_dispatch:
jobs:
deploy:
name: Deploy to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build requests
- name: Run TestPyPI auto versioning
if: github.event_name == 'workflow_dispatch'
run: |
next_version=$(python src/auto_version.py --test)
echo "__version__ = '$next_version'" > src/_version.py
echo "Updated version to $next_version in src/_version.py"
- name: Run PyPI auto versioning
if: github.event_name == 'push'
run: |
next_version=$(python src/auto_version.py)
echo "__version__ = '$next_version'" > src/_version.py
echo "Updated version to $next_version in src/_version.py for official release"
- name: Build package
run: |
python -m build
- name: Publish package to TestPyPI
if: github.event_name == 'workflow_dispatch'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
if: github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}