-
-
Notifications
You must be signed in to change notification settings - Fork 1k
184 lines (170 loc) · 5.54 KB
/
setup.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
183
184
# Copyright © Michal Čihař <michal@weblate.org>
#
# SPDX-License-Identifier: GPL-3.0-or-later
name: Distribution
on:
push:
branches-ignore:
- deepsource-fix-**
- renovate/**
- weblate
tags:
- weblate-*
pull_request:
permissions:
contents: read
jobs:
setup:
runs-on: ubuntu-22.04
env:
PYTHONUNBUFFERED: 1
PYTHONWARNINGS: default,ignore:unclosed:ResourceWarning
steps:
- uses: actions/checkout@v4
- name: Install apt dependencies
run: sudo ./ci/apt-install
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Used versions
run: ./ci/print-versions
- name: Install Python dependencies
run: ./ci/pip-install
- name: Install setuptools
run: uv pip install --system $(sed -n 's/.*"\(setuptools[<>=]=\([^"]*\)\)".*/\1/p' pyproject.toml)
- name: Install Weblate
run: coverage run ./setup.py install
- name: Check difference
run: diff -ruNqp weblate $(python -c 'import weblate; import os; print(os.path.dirname(weblate.__file__))')
- name: Coverage
run: |
coverage combine
coverage xml
- uses: codecov/codecov-action@v4
with:
token: ${{secrets.CODECOV_TOKEN}}
flags: setup
name: setup
pip:
runs-on: ubuntu-22.04
env:
PYTHONUNBUFFERED: 1
PYTHONWARNINGS: default,ignore:unclosed:ResourceWarning
steps:
- uses: actions/checkout@v4
- name: Install apt dependencies
run: sudo ./ci/apt-install
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Used versions
run: ./ci/print-versions
- name: Install Python dependencies
run: ./ci/pip-install
- name: Install Weblate
run: uv pip install --system '.[all]'
- name: Check difference
run: diff -ruNqp weblate $(python -c 'import weblate; import os; print(os.path.dirname(weblate.__file__))')
dist:
runs-on: ubuntu-22.04
env:
PYTHONUNBUFFERED: 1
PYTHONWARNINGS: default,ignore:unclosed:ResourceWarning
permissions:
# Needed for Sigstore
id-token: write
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Python dependencies
run: |
python -m pip install $(sed -n 's/.*"\(uv==\([^"]*\)\)".*/\1/p' pyproject.toml)
uv pip install --system $(sed -n 's/.*"\(twine==\([^"]*\)\)".*/\1/p' pyproject.toml)
uv pip install --system $(sed -n 's/.*"\(build==\([^"]*\)\)".*/\1/p' pyproject.toml)
- name: build
run: python -m build
- name: Twine check
run: twine check dist/*
- name: Sign the dists with Sigstore
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/weblate')
uses: sigstore/gh-action-sigstore-python@v2.1.1
with:
inputs: dist/*
- uses: actions/upload-artifact@v4
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/weblate')
with:
path: dist/*
name: dist
notes:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install apt dependencies
run: |
sudo apt update
sudo apt install -y graphviz pandoc
- name: Install Python dependencies
run: |
python -m pip install $(sed -n 's/.*"\(uv==\([^"]*\)\)".*/\1/p' pyproject.toml)
uv pip install --system -r docs/requirements.txt
- name: Sphinx build
run: ./ci/run-docs
- name: Convert release notes
run: |
version=$(sed -n '/^VERSION =/ s/.*"\(.*\)"/\1/p' weblate/utils/version.py)
namever="weblate-$version"
sed "s/latest/$namever/" < scripts/release-notes-filter.lua > scripts/release-notes-filter.version.lua
mkdir dist
./scripts/extract-release-notes > "dist/Weblate-$version.html"
pandoc "dist/Weblate-$version.html" --write=gfm --wrap=none --lua-filter=scripts/release-notes-filter.version.lua -o "dist/Weblate-$version.md"
rm scripts/release-notes-filter.version.lua
- uses: actions/upload-artifact@v4
with:
path: dist/*
name: notes
publish_pypi:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/weblate')
permissions:
# this permission is mandatory for trusted publishing
id-token: write
needs:
- notes
- dist
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v4
- name: Cleanup dist
# Remove files not supported on PyPI (eg. Sigstore signatures)
run: find dist -mindepth 1 -not -name '*.tar.gz' -not -name '*.whl' -delete
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
publish_github:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/weblate')
permissions:
# this permission is mandatory for creating a release
contents: write
needs:
- notes
- dist
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v4
- name: Extract notes body
run: tail -n+3 notes/Weblate-*.md > notes.md
- name: Extract notes title
id: get-name
run: echo name=$(head -n1 notes/Weblate-*.md) > "$GITHUB_OUTPUT"
- uses: ncipollo/release-action@v1
with:
artifacts: dist/*
bodyFile: notes.md
name: ${{ steps.get-name.outputs.name }}