-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (168 loc) · 5.12 KB
/
Copy pathpublish.yml
File metadata and controls
190 lines (168 loc) · 5.12 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: publish
on:
workflow_dispatch:
inputs:
repository:
description: Publish target repository
required: true
default: testpypi
type: choice
options:
- testpypi
- pypi
release:
types: [published]
push:
tags:
- "v*"
jobs:
pytest-modern:
name: pytest (Python ${{ matrix.python-version }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version:
- "3.7"
- "3.8"
- "3.10"
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up uv
uses: astral-sh/setup-uv@v5
- name: Sync dependencies
run: uv sync --dev
- name: Run pytest
run: uv run pytest
pytest-py36:
name: pytest (Python 3.6)
runs-on: ubuntu-22.04
container:
image: python:3.6.15-slim-bullseye
steps:
- name: Install system dependencies
run: |
printf '%s\n' \
'deb [check-valid-until=no] https://archive.debian.org/debian bullseye main' \
> /etc/apt/sources.list
apt-get -o APT::Update::Error-Mode=any update
apt-get install -y --no-install-recommends git nodejs npm
- name: Check out repository
uses: actions/checkout@v4
- name: Mark workspace as safe for git
run: git config --global --add safe.directory "$PWD"
- name: Show runtime versions
run: |
python --version
pip --version
git --version
node --version
- name: Install Python 3.6 compatibility dependencies
run: |
python -m pip install -i https://pypi.org/simple \
"dataclasses>=0.8" \
"typing_extensions>=4.1.1,<4.2" \
"importlib_metadata>=4.8.3,<5" \
"tomli>=1.2.3,<2" \
"requests>=2.27.1" \
"prompt-toolkit>=3.0.36,<3.1" \
"pyyaml>=6.0" \
"loguru>=0.7.3,<1" \
"pycryptodomex>=3.20" \
"pillow>=8.4.0,<9" \
"fastapi>=0.83,<0.84" \
"uvicorn>=0.16,<0.17" \
"pytest>=6.2.5,<7" \
"pytest-asyncio>=0.16,<0.17"
- name: Run Python 3.6 pytest
env:
PYTHONPATH: ${{ github.workspace }}
run: python -m pytest -c /dev/null
build:
needs:
- pytest-modern
- pytest-py36
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build distributions
run: |
python -m pip install --upgrade build twine
python -m build --outdir dist/python-codex .
python -m build --outdir dist/pycodex-ws packages/pycodex-ws
python -m twine check dist/python-codex/* dist/pycodex-ws/*
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-testpypi:
if: github.event_name == 'workflow_dispatch' && inputs.repository == 'testpypi'
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: testpypi
url: https://test.pypi.org/project/python-codex/
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/python-codex/
repository-url: https://test.pypi.org/legacy/
publish-pypi:
if: github.event_name == 'release' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.repository == 'pypi')
needs: build
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/project/python-codex/
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/python-codex/
publish-pycodex-ws:
if: github.event_name == 'release' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.repository == 'pypi')
needs:
- build
- publish-pypi
runs-on: ubuntu-latest
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/project/pycodex-ws/
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish pycodex-ws to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/pycodex-ws/