-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (109 loc) · 3.14 KB
/
ci.yaml
File metadata and controls
111 lines (109 loc) · 3.14 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
name: Test package
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
jobs:
test:
name: Test package
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version:
- "3.12"
- "3.13"
type:
- test
include:
- os: ubuntu-latest
python-version: "3.13"
type: code style
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
# Tests
- name: Install test dependencies
if: ${{ matrix.type == 'test' }}
run: python -m pip install . --group test
- name: Check types
if: ${{ matrix.type == 'test' }}
run: pyright
- name: Test package
if: ${{ matrix.type == 'test' }}
run: pytest -vv --showlocals --tb=short --color=yes --junit-xml=test-results.xml
# Lint
- name: Install lint dependencies
if: ${{ matrix.type == 'code style' }}
run: python -m pip install . --group lint
- name: Check code style
if: ${{ matrix.type == 'code style' }}
run: pre-commit run -a
publish_to_pypi:
name: Publish package to PyPi
needs:
- test
if: ${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') }}
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/sphinx-syntax
permissions:
contents: write
id-token: write
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate release metadata
id: metadata
run: |
ref="${{ github.ref }}";
version=${ref#refs/tags/v};
link="https://pypi.org/p/sphinx-syntax/${version}/";
echo "version=${version}" >> $GITHUB_OUTPUT
echo "link=${link}" >> $GITHUB_OUTPUT
- name: Parse Changelog
id: changelog
uses: mindsers/changelog-reader-action@v2
with:
version: ${{ steps.metadata.outputs.version }}
- name: Set up python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install build
run: |
pip install build
- name: Build project
run: |
python3 -m build .
- name: Publish to pypi
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: false
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
prerelease: ${{ steps.changelog.outputs.status == 'prereleased' }}
draft: ${{ steps.changelog.outputs.status == 'unreleased' }}
body: |
## Changelog
${{ steps.changelog.outputs.changes }}
[See release on PyPi](${{ steps.metadata.outputs.link }})