-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (86 loc) · 2.58 KB
/
ci-cd.yml
File metadata and controls
103 lines (86 loc) · 2.58 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
name: CI/CD Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ created ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
version: latest
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg
- name: Install dependencies
run: |
# Install all dependency groups needed for tests
uv sync --all-extras --all-groups
- name: Run tests
run: |
uv run pytest
build-and-publish:
needs: test
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' && github.event.action == 'created' }}
environment:
name: pypi
url: https://pypi.org/p/<your-pypi-project-name>
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
version: latest
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg
- name: Extract version from tag
id: get_version
run: |
# Extract tag name from github.ref (e.g., 'refs/tags/v1.2.3' -> 'v1.2.3')
TAG=${GITHUB_REF#refs/tags/}
# Remove 'v' prefix if present (e.g., 'v1.2.3' -> '1.2.3')
VERSION=${TAG#v}
# Set output for use in later steps
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version: $VERSION"
- name: Update version in pyproject.toml
run: |
# Use sed to replace the version line in pyproject.toml
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml
echo "Updated pyproject.toml with version $VERSION"
cat pyproject.toml | grep version
- name: Build package
run: |
uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/