-
Notifications
You must be signed in to change notification settings - Fork 170
182 lines (170 loc) · 7.16 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
on:
push:
branches: [main]
pull_request:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
python_version: '3.13'
name: CI
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 10
if: "!contains(github.event.head_commit.message, 'skip ci')"
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ env.python_version }}
- name: Install uv
uses: astral-sh/setup-uv@e779db74266a80753577425b0f4ee823649f251d # v3.2.3
with:
enable-cache: true
cache-dependency-glob: ".pre-commit-config.yaml"
- name: Install pre-commit
run: uv tool install pre-commit --with pre-commit-uv
- name: Lint with pre-commit
run: pre-commit run --show-diff-on-failure --color=always --all-files
- name: Check uv lock file integrity
run: uv lock --locked --offline
test:
needs: lint
name: Test with Python ${{ matrix.python-version }}
runs-on: windows-latest
timeout-minutes: 60
if: "!contains(github.event.head_commit.message, 'skip ci')"
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install uv
uses: astral-sh/setup-uv@e779db74266a80753577425b0f4ee823649f251d # v3.2.3
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install the project
run: uv sync
- name: Install tox
run: uv tool install tox --with tox-uv
- name: Setup test suite
run: tox run --notest --skip-missing-interpreters false
- name: Run test suite
run: tox run --skip-pkg-install
build:
needs: lint
name: Build GTK${{ matrix.gtk-version }} Binaries
runs-on: windows-latest
permissions:
contents: write
timeout-minutes: 75
if: "!contains(github.event.head_commit.message, 'skip ci')"
strategy:
matrix:
gtk-version: ['3', '4']
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: ${{ env.python_version }}
- name: Install uv
uses: astral-sh/setup-uv@e779db74266a80753577425b0f4ee823649f251d # v3.2.3
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Seed pip
run: uv venv --seed
- name: Install the project
run: uv sync --no-dev
- name: Build GTK3
if: matrix.gtk-version == '3'
run: >
uv run gvsbuild build --ninja-opts -j2 --enable-gi --py-wheel gtk3 gtksourceview4 graphene pygobject
adwaita-icon-theme glib-networking
- name: Build GTK4
if: matrix.gtk-version == '4'
run: > # Use -j2 option to prevent out of memory errors with GitHub Action runners
uv run gvsbuild build --ninja-opts -j2 --enable-gi --py-wheel gtk4 libadwaita gtksourceview5 pygobject
adwaita-icon-theme gtkmm
- name: Copy wheel files
run: |
New-Item "C:\gtk-build\gtk\x64\release\wheels" -ItemType "directory"
Copy-Item (Resolve-Path C:\gtk-build\build\x64\release\pygobject\dist\PyGObject*.whl) "C:\gtk-build\gtk\x64\release\wheels"
Copy-Item (Resolve-Path C:\gtk-build\build\x64\release\pycairo\dist\pycairo*.whl) "C:\gtk-build\gtk\x64\release\wheels"
- name: Archive GTK runtime
run: 7z a -tzip GTK${{ matrix.gtk-version }}_Gvsbuild_${{ github.sha }}_x64.zip C:\gtk-build\gtk\x64\release\*
- name: Upload GTK${{ matrix.gtk-version }}_Gvsbuild-${{ github.sha }}_x64.zip
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: GTK${{ matrix.gtk-version }}_Gvsbuild_${{ github.sha }}_x64.zip
path: GTK${{ matrix.gtk-version }}_Gvsbuild_${{ github.sha }}_x64.zip
- name: Upload Release Assets
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
mv GTK${{ matrix.gtk-version }}_Gvsbuild_${{ github.sha }}_x64.zip GTK${{ matrix.gtk-version }}_Gvsbuild_${{ github.event.release.tag_name }}_x64.zip
gh release upload ${{ github.event.release.tag_name }} "GTK${{ matrix.gtk-version }}_Gvsbuild_${{ github.event.release.tag_name }}_x64.zip"
- name: Cleanup Zip Files
if: github.event_name == 'release'
run: rm GTK${{ matrix.gtk-version }}_Gvsbuild_${{ github.event.release.tag_name }}_x64.zip
- name: Create Source Dist and Wheel
if: matrix.gtk-version == '4'
run: uv build
- name: Upload gvsbuild-${{ github.event.release.tag_name }}.tar.gz
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: github.event_name == 'release' && matrix.gtk-version == '4'
with:
name: gvsbuild-${{ github.event.release.tag_name }}.tar.gz
path: dist/gvsbuild-${{ github.event.release.tag_name }}.tar.gz
- name: Upload gvsbuild-${{ github.event.release.tag_name }}-py3-none-any.whl
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: github.event_name == 'release' && matrix.gtk-version == '4'
with:
name: gvsbuild-${{ github.event.release.tag_name }}-py3-none-any.whl
path: dist/gvsbuild-${{ github.event.release.tag_name }}-py3-none-any.whl
publish-to-pypi:
name: Publish to PyPI (release only)
needs: build
runs-on: ubuntu-22.04
permissions:
id-token: write
if: ${{ github.event_name == 'release' }}
steps:
- name: Download tar.gz
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: gvsbuild-${{ github.event.release.tag_name }}.tar.gz
path: dist
- name: Download wheel
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: gvsbuild-${{ github.event.release.tag_name }}-py3-none-any.whl
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2