-
Notifications
You must be signed in to change notification settings - Fork 336
104 lines (90 loc) · 2.99 KB
/
python_publish.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
101
102
103
104
# This workflow will upload a Python Package using Twine when a release is created.
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [created] # Only publish on tagged releases
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pipx install pre-commit
- run: pre-commit install
- run: pre-commit run --all-files
test:
needs: [pre-commit]
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ['3.9', '3.11', '3.13']
max-parallel: 9
runs-on: ${{ matrix.os }}
steps:
- if: runner.os == 'Linux'
run: sudo apt-get update -q -q && sudo apt-get install --yes espeak-ng libespeak1
- if: runner.os == 'macOS'
run: brew install espeak-ng
- name: Download and install eSpeak-NG
if: runner.os == 'Windows'
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://github.com/espeak-ng/espeak-ng/releases/download/1.51/espeak-ng-X64.msi" -OutFile "espeak-ng.msi"
Start-Process msiexec.exe -ArgumentList '/i espeak-ng.msi /quiet /norestart' -Wait
# dir "$env:ProgramFiles\eSpeak NG"
$env:Path += ";$env:ProgramFiles\eSpeak NG"
espeak-ng --version
- if: runner.os != 'Windows'
run: espeak-ng --version
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade pip
pip install pytest
pip install --editable .
- timeout-minutes: 10 # Save resources while our pytests are hanging
run: pytest -s -vvv --strict
build:
runs-on: ubuntu-latest
needs: [test] # This ensures tests pass before build
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install build twine
- name: Clean previous builds
run: |
rm -rf dist
- name: Build package
run: |
python -m build
python -m twine check --strict dist/*
deploy:
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'created' # Only on release creation
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_PASSWORD }}