-
Notifications
You must be signed in to change notification settings - Fork 2
227 lines (187 loc) · 5.83 KB
/
main.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
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
name: Main
on:
push:
branches: [main]
tags:
- "v*"
pull_request:
branches: [main]
permissions:
contents: read
jobs:
lint:
name: Lint code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
cache: poetry
- name: Install deps
run: poetry install
- name: Lint code
run: poetry run poe lint
tests:
name: Tests
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12", "3.13"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: poetry
- name: Install deps
run: poetry install
- name: Run tests
run: poetry run poe test
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
uses: codecov/codecov-action@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # v3.1.5
pypi-deploy:
name: Release to PyPI
if: github.ref_type == 'tag'
needs: [lint, tests]
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: |
pipx install poetry
pipx inject poetry poetry-dynamic-versioning[plugin]
- uses: actions/setup-python@v5
- name: Build package
run: poetry build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597 # v1.10.3
aur-deploy:
name: Release to AUR
if: true && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta')
needs: [pypi-deploy]
environment:
name: aur
url: https://aur.archlinux.org/packages/python-images-upload-cli
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Wait for PyPI update
run: sleep 10
- name: Update version in PKGBUILD
run: |
sed "s|^pkgver=.*$|pkgver=\"${GITHUB_REF_NAME#v}\"|" -i PKGBUILD
- name: Deploy PKGBUILD to the Arch User Repository
uses: ksxgithub/github-actions-deploy-aur@a97f56a8425a7a7f3b8c58607f769c69b089cadb # v3.0.1
with:
pkgname: python-images-upload-cli
pkgbuild: ./PKGBUILD
commit_username: DeadNews
commit_email: [email protected]
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Upstream release ${{ github.ref_name }}
updpkgsums: true
github-deploy:
name: Release to GitHub
if: github.ref_type == 'tag'
needs: [lint, tests]
environment: github-releases
permissions:
contents: write
env:
CHANGELOG: https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md
PRERELEASE: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create GitHub Release
run: |
gh release create ${{ github.ref_name }} \
--title ${{ github.ref_name }} \
--notes="See [the CHANGELOG](${{ env.CHANGELOG }}) for more details." \
--draft=${{ env.PRERELEASE }} \
--prerelease=${{ env.PRERELEASE }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-win:
name: Windows Build
if: github.ref_type == 'tag'
needs: [github-deploy]
environment: github-releases
permissions:
contents: write
env:
ASSET: ${{ github.event.repository.name }}_${{ github.ref_name }}_windows_amd64.zip
BINARY: ${{ github.event.repository.name }}.exe
NUITKA_CACHE_DIR: /cache/nuitka
PYTHON_VERSION: "3.12"
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: poetry
- name: Install deps
run: poetry install
- name: Cache nuitka
uses: actions/cache@v4
with:
key: ${{ runner.os }}-nuitka
path: ${{ env.NUITKA_CACHE_DIR }}
- name: Build binaries
run: poetry run poe nuitka --output-file ${{ env.BINARY }}
- name: Archive binaries
run: poetry run python -m zipfile --create ${{ env.ASSET }} dist/${{ env.BINARY }}
- name: Upload binaries to Release
run: gh release upload ${{ github.ref_name }} ${{ env.ASSET }}
env:
GITHUB_TOKEN: ${{ github.token }}
docs-build:
name: Build docs
if: github.ref_type == 'tag'
needs: [lint, tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
cache: poetry
- name: Install deps
run: poetry install
- name: Build docs
run: poetry run mkdocs build
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: site
docs-deploy:
name: Deploy docs
if: true && !contains(github.ref, 'alpha')
needs: [docs-build]
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
id-token: write
pages: write
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4