-
Notifications
You must be signed in to change notification settings - Fork 3
129 lines (109 loc) · 3.09 KB
/
ci.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
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
name: Run CI
on:
push:
branches: "*"
tags: 'v[0-9]+![0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches: "*"
schedule:
# run every Saturday at 11 EST / 12 EDT
# because new Pydantic versions keep breaking things :(
- cron: 0 16 * * 6
permissions:
contents: read
env:
PYPI_PACKAGE: hexdoc
PYTHON_VERSION: '3.11'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
pages: read
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEXDOC_RELEASE: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
outputs:
release: ${{ env.HEXDOC_RELEASE }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: yezz123/setup-uv@v4
- name: Install display server
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: xvfb
- name: Install dependencies
run: uv pip install --system -e .
- name: Export hexdoc resources
run: xvfb-run --auto-servernum hexdoc ci build
- name: Upload package artifact
uses: actions/upload-artifact@v3
with:
name: python-build
path: dist
test:
runs-on: ubuntu-latest
env:
HEXDOC_RELEASE: false
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: yezz123/setup-uv@v4
- name: Install display server
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: xvfb
- name: Run pre-commit hooks
env:
SKIP: pyright
uses: pre-commit/action@v3.0.0
- name: Install Nox
run: uv pip install --system nox
- name: Run Nox with display server
run: xvfb-run --auto-servernum nox
update-tags:
runs-on: ubuntu-latest
needs: [build, test]
if: github.event_name == 'push' && needs.build.outputs.release == 'true'
permissions:
contents: write
concurrency:
group: update-tags-${{ github.sha }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: yezz123/setup-uv@v4
- name: Install Nox
run: uv pip install --system nox packaging
- name: Run Nox
run: nox --session tag
- name: Push new tags
run: git push --tags --force
publish-pypi:
runs-on: ubuntu-latest
needs: [build, test]
if: github.event_name == 'push' && needs.build.outputs.release == 'true'
environment:
name: pypi
url: https://pypi.org/p/${{ env.PYPI_PACKAGE }}
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Download package artifact
uses: actions/download-artifact@v3
with:
name: python-build
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1