-
Notifications
You must be signed in to change notification settings - Fork 5
102 lines (84 loc) · 2.52 KB
/
Copy pathpypi-publish.yml
File metadata and controls
102 lines (84 loc) · 2.52 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
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
101
102
name: Publish Python SDK to PyPI
on:
release:
types: [created]
workflow_dispatch:
inputs:
environment:
description: 'Environment'
required: true
default: 'test'
type: choice
options:
- test
- prod
jobs:
publish-testpypi:
if: github.event.inputs.environment == 'test' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'test')
runs-on: ubuntu-latest
environment:
name: testpypi
url: https://test.pypi.org/projects/a3m-router
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install build twine
- name: Build package
run: |
cd python
python -m build
- name: Publish to Test PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
run: |
cd python
python -m twine upload --repository testpypi dist/*
publish-pypi:
if: github.event.inputs.environment == 'prod' || github.event_name == 'release'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/projects/a3m-router
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install build twine
- name: Build package
run: |
cd python
python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
cd python
python -m twine upload dist/*
test-package:
runs-on: ubuntu-latest
needs: publish-testpypi
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install from Test PyPI
env:
TWINE_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}
run: |
pip install --index-url https://test.pypi.org/simple/ a3m-router
- name: Test import
run: |
python -c "from a3m import A3MRouter, __version__; print(f'A3M Router SDK v{__version__} installed successfully!')"