-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (83 loc) · 2.44 KB
/
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Publish CADET-RDM to PyPI
on:
push:
branches:
- master
- dev
- test_ci
tags:
- 'v*.*.*' # Trigger build stage only on version tags
pull_request:
branches:
- '**' # Trigger test stage on pull requests to any branch
jobs:
test-stage:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.10", "3.11", "3.12" ]
include:
- os: windows-latest
python-version: "3.12"
- os: macos-12
python-version: "3.12"
steps:
- name: Checkout Code
uses: actions/checkout@master
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Git LFS
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
sudo apt-get update
sudo apt-get install -y git-lfs
git lfs install
- name: Configure Git # This is required for the test suite, which checks git credentials
run: |
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
- name: Set up Virtual Environment
run: |
python -m venv ../testing
${{ runner.os == 'Windows' && 'source ../testing/Scripts/activate' || 'source ../testing/bin/activate' }}
- name: Install Dependencies
run: |
pip install -U pytest setuptools
pip install .[testing]
- name: Verify Installation
run: |
pip list
ls -l
- name: Run Tests
run: |
pytest tests -m "not server_api"
build-release:
name: Build and Upload Release
runs-on: ubuntu-latest
needs: test-stage # Ensure this job runs only after test-stage succeeds
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install Build Tools
run: |
pip install -U build twine
- name: Build the Package
run: |
python -m build
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }}
run: |
python -m twine upload dist/*