-
Notifications
You must be signed in to change notification settings - Fork 19
268 lines (217 loc) · 7.63 KB
/
main.yaml
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# SPDX-FileCopyrightText: 2024 geisserml <geisserml@gmail.com>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
name: Main packaging
on:
workflow_dispatch:
inputs:
pre_test:
default: false
type: boolean
test:
default: true
type: boolean
publish:
default: false
type: boolean
conda:
default: false
type: boolean
py_version:
default: '3.10'
type: string
runner:
default: 'ubuntu-latest'
type: string
defaults:
run:
shell: bash
jobs:
# TODO sync sourcebuild patches & third-party licenses with pdfium-binaries on before release?
# TODO(201): schedule test_setup and test_sourcebuild separately
test_setup:
if: ${{ inputs.pre_test }}
uses: ./.github/workflows/test_setup.yaml
test_sourcebuild:
if: ${{ inputs.pre_test }}
uses: ./.github/workflows/test_sourcebuild.yaml
build:
runs-on: ${{ inputs.runner }}
outputs:
new_version: ${{ steps.get_version.outputs.new_version }}
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.py_version }}
- name: Check out repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
fetch-depth: 0
- name: Install/update dependencies
run: python3 -m pip install -U -r req/setup.txt -r req/test.txt -r req/utilities.txt
# NOTE autorelease sets a tag, but it's just temporary for informational purpose and does not match the actually published tag
# We can't push the tag at this stage because we don't know the outcome of the following jobs yet
- name: Run autorelease script
run: |
git config user.email "geisserml@gmail.com"
git config user.name "geisserml"
git reset --hard HEAD
python3 setupsrc/pypdfium2_setup/autorelease.py --register
git checkout autorelease_tmp
- name: Get new version
id: get_version
run: echo "new_version=$(git describe --abbrev=0)" >> $GITHUB_OUTPUT
- name: Install pypdfium2
run: python3 -m pip install --no-build-isolation -e .
- name: Run test suite
run: ./run test
- name: Run PyPI packaging script
run: ./run packaging_pypi
- name: Upload release notes
uses: actions/upload-artifact@v4
with:
name: release_notes
path: RELEASE.md
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: packages
path: dist/*
# tag deliberately not pushed (see above)
- name: Push autorelease_tmp branch
run: git push -u origin autorelease_tmp
test:
if: ${{ inputs.test }}
needs: build
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
py: ['3.7', '3.8', '3.9', '3.10', '3.11']
include:
- os: ubuntu-latest
wheel: dist/*manylinux_*_x86_64*.whl
- os: macos-latest
wheel: dist/*macosx_*_x86_64*.whl
- os: windows-latest
wheel: dist/*win_amd64.whl
runs-on: ${{ matrix.os }}
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py }}
- name: Check out repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: autorelease_tmp
- name: Download packages
uses: actions/upload-artifact@v4
with:
name: packages
path: dist/
- name: Install dependencies
run: |
python3 -m pip install -U pip setuptools
python3 -m pip install -U pytest pillow numpy wheel
- name: Install pypdfium2 from artifact
run: python3 -m pip install ${{ matrix.wheel }}
- name: Run Test Suite
run: ./run test
publish:
needs: [test_setup, test_sourcebuild, build, test]
if: ${{ inputs.publish && !cancelled() && !contains(needs.*.result, 'failure') }}
runs-on: ${{ inputs.runner }}
environment: release # PyPI upload via "trusted publishing"
permissions:
id-token: write # PyPI upload via "trusted publishing"
contents: write # autorelease repository changes
actions: write # GH pages workflow-dispatch
steps:
- name: Check out repository (deep)
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.py_version }}
- name: Download packages
uses: actions/upload-artifact@v4
with:
name: packages
path: dist/
- name: Download release notes
uses: actions/upload-artifact@v4
with:
name: release_notes
- name: Apply and push repository changes
run: |
git config user.email "geisserml@gmail.com"
git config user.name "geisserml"
git checkout main
git merge origin/autorelease_tmp
git tag -a ${{ needs.build.outputs.new_version }} -m "Autorelease"
git push
git push --tags
git checkout stable
git reset --hard main
git push --force
git checkout main
# Upload to TestPyPI / PyPI via "trusted publishing".
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
# https://docs.pypi.org/trusted-publishers/using-a-publisher/
# https://github.com/pypa/gh-action-pypi-publish
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: dist/ # the default
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/ # the default
- name: Publish to GitHub
uses: ncipollo/release-action@v1
with:
artifacts: 'dist/*'
bodyFile: 'RELEASE.md'
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.build.outputs.new_version }}
prerelease: ${{ contains(needs.build.outputs.new_version, 'b') }}
- name: Trigger GH Pages rebuild
uses: benc-uk/workflow-dispatch@v1
with:
workflow: gh_pages.yaml # takes no inputs
conda_trigger:
needs: [build, test, publish]
if: ${{ inputs.conda && !cancelled() && !contains(needs.*.result, 'failure') }}
runs-on: ${{ inputs.runner }}
steps:
- name: Trigger conda pypdfium2_helpers build
uses: benc-uk/workflow-dispatch@v1
with:
# FIXME input not respected for py_version here
workflow: conda.yaml
inputs: |
{
"package": "helpers",
"pdfium_ver": "latest",
"test": "true",
"publish": "${{ inputs.publish }}",
"py_version": "3.11"
}
cleanup:
needs: [build, test, publish, conda_trigger]
if: ${{ !cancelled() }}
runs-on: ${{ inputs.runner }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
- name: Remove temporary branch
run: git push origin --delete autorelease_tmp