-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (81 loc) · 2.66 KB
/
cicd.yml
File metadata and controls
84 lines (81 loc) · 2.66 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
name: Continuous Integration and Deployment
on: # events that trigger this workflow
# UNCOMMENT THE LINES BELOW TO ACTIVATE THE WORKFLOW
#push:
# branches:
# - main
#pull_request:
# branches:
# - main
#release:
# types: [created]
#workflow_dispatch: # manual trigger
jobs:
test:
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
steps:
# Checkout repo
- name: Checkout
uses: actions/checkout@v3
# Install uv with cache
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
# Sync dependencies
- name: Sync dependencies
run: uv sync
# Run tests without updating uv.lock
- name: Run tests
run: uv run --frozen pytest
# Code coverage to codecov.io disabled
# allows you to publish test code coverage, and link to a README badge
# uncomment block below if you set up codecov - see: https://about.codecov.io/
# note that codecov uses coverage.xml in tests/. This is an output configured in pyproject.toml for pytest
# - name: Upload results to Codecov
# uses: codecov/codecov-action@v4
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: tests/coverage.xml
# fail_ci_if_error: false
# verbose: true
# Third job publishes to PyPi if tests are passed and release is created
# To create a release, you need to create a git tag then a GitHub release
# See https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases
# To publish to PyPI, you will need PyPI account and to setup trusted publishing
publish:
if: github.event_name == 'release' && github.event.action == 'created'
needs: test
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/your-package/
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
# Checkout repo
- name: Checkout
uses: actions/checkout@v3
# Install uv with cache
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
# Sync dependencies
- name: Sync dependencies
run: uv sync
# Build
- name: Build
run: uv build
# Publish to PyPI
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1