-
Notifications
You must be signed in to change notification settings - Fork 0
262 lines (244 loc) · 8.42 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
# Continuous Integration/Deployment pipeline
name: "CI/CD Workflow"
run-name: |
CI/CD: ${{ github.ref }}
on:
issues:
issue_comment:
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
pull_request_review:
pull_request_review_comment:
pull_request_target:
types:
- opened
- reopened
- synchronize
push:
schedule:
- cron: '0 0 * * *' # Every day at midnight UTC.
- cron: '0 0 * * 1' # Every Monday at midnight UTC.
workflow_dispatch:
inputs:
meta-sync:
type: choice
options:
- report
- amend
- commit
- pull
- none
default: report
required: true
description: |
The action to take when the dynamic files are out of sync with the repository meta content.
Selecting 'none' will disable this action.
hooks:
type: choice
options:
- report
- amend
- commit
- pull
- none
default: report
required: true
description: |
The action to take when running the workflow hooks.
Selecting 'none' will disable this action.
package-build:
type: boolean
required: false
default: false
description: |
Build the package and upload the builds as artifacts.
package-lint:
type: boolean
required: false
default: false
description: |
Run the linting workflow.
package-test:
type: boolean
required: false
default: false
description: |
Run the test workflow on package.
website-build:
type: boolean
required: false
default: false
description: |
Build the documentation with Sphinx and upload the builds as artifacts.
jobs:
init:
name: 'RepoDynamics'
uses: ./.github/workflows/_repodynamics.yaml
permissions:
contents: write
issues: write
pull-requests: write
with:
package-build: ${{ inputs.package-build || false }}
package-lint: ${{ inputs.package-lint || false }}
package-test: ${{ inputs.package-test || false }}
website-build: ${{ inputs.website-build || false }}
meta-sync: ${{ inputs.meta-sync }}
hooks: ${{ inputs.hooks }}
secrets:
repo-admin-token: ${{ secrets.REPO_ADMIN_TOKEN }}
build:
name: 'Package Build'
needs: init
if: fromJSON(needs.init.outputs.config).run.package_build
uses: ./.github/workflows/_pkg_build.yaml
with:
metadata: ${{ needs.init.outputs.metadata }}
ref: ${{ fromJSON(needs.init.outputs.config).checkout.ref }}
repository: ${{ fromJSON(needs.init.outputs.config).checkout.repository }}
test:
name: 'Package Test: Local'
needs: init
if: fromJSON(needs.init.outputs.config).run.package_test_local
uses: ./.github/workflows/_pkg_test.yaml
with:
metadata: ${{ needs.init.outputs.metadata }}
ref: ${{ fromJSON(needs.init.outputs.config).checkout.ref }}
repository: ${{ fromJSON(needs.init.outputs.config).checkout.repository }}
package-source: GitHub
lint:
name: 'Package Lint'
needs: init
if: fromJSON(needs.init.outputs.config).run.package_lint
permissions:
pull-requests: write
security-events: write
actions: read
contents: read
uses: ./.github/workflows/_pkg_lint.yaml
with:
metadata: ${{ needs.init.outputs.metadata }}
ref: ${{ fromJSON(needs.init.outputs.config).checkout.ref }}
ref-before: ${{ fromJSON(needs.init.outputs.config).checkout.ref_before }}
website:
name: 'Website / Build'
needs: init
if: fromJSON(needs.init.outputs.config).run.website_build
permissions:
contents: read
pages: write
id-token: write
environment:
name: GitHub Pages
url: ${{ fromJSON(needs.init.outputs.metadata).url.website.base }}
runs-on: ubuntu-latest
steps:
- uses: RepoDynamics/SphinxDocs@main
with:
ref: ${{ fromJSON(needs.init.outputs.config).checkout.ref }}
deploy: ${{ fromJSON(needs.init.outputs.config).run.website_deploy }}
path-website: ${{ fromJSON(needs.init.outputs.metadata).path.dir.website }}
path-package-setup: "."
website-rtd-preview:
# Build the ReadTheDocs website for pull-requests and add a link to the pull request's description.
# Note: Enable "Preview Documentation from Pull Requests" in ReadtheDocs project at https://docs.readthedocs.io/en/latest/pull-requests.html
name: 'Website / Preview'
needs: init
if: fromJSON(needs.init.outputs.config).run.website_rtd_preview
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: 'Build Preview'
# https://github.com/readthedocs/actions/tree/v1/preview
uses: readthedocs/actions/preview@v1
with:
project-slug: ${{ fromJSON(needs.init.outputs.metadata).web.readthedocs.name }}
publish-testpypi:
name: 'Package Publish'
needs: [init, build, test, lint]
if: fromJSON(needs.init.outputs.config).run.package_publish_testpypi
permissions:
id-token: write
uses: ./.github/workflows/_pkg_publish.yaml
with:
platform: TestPyPI
download-url: ${{ fromJSON(needs.init.outputs.config).package.download_url_testpypi }}
upload-url: ${{ fromJSON(needs.init.outputs.config).package.upload_url_testpypi }}
test-testpypi:
name: 'Package Test: TestPyPI'
needs: [init, publish-testpypi]
if: ${{ !failure() && fromJSON(needs.init.outputs.config).run.package_test_testpypi }}
uses: ./.github/workflows/_pkg_test.yaml
with:
metadata: ${{ needs.init.outputs.metadata }}
ref: ${{ fromJSON(needs.init.outputs.config).checkout.ref }}
repository: ${{ fromJSON(needs.init.outputs.config).checkout.repository }}
package-source: TestPyPI
package-version: ${{ fromJSON(needs.init.outputs.config).package.version }}
publish-pypi:
name: 'Package Publish'
needs: [init, test-testpypi]
if: ${{ !failure() && fromJSON(needs.init.outputs.config).run.package_publish_pypi }}
permissions:
id-token: write
uses: ./.github/workflows/_pkg_publish.yaml
with:
platform: PyPI
download-url: ${{ fromJSON(needs.init.outputs.config).package.download_url_pypi }}
upload-url: ${{ fromJSON(needs.init.outputs.config).package.upload_url_pypi }}
test-pypi:
name: 'Package Test: PyPI'
needs: [init, publish-pypi]
if: ${{ !failure() && fromJSON(needs.init.outputs.config).run.package_test_pypi }}
uses: ./.github/workflows/_pkg_test.yaml
with:
metadata: ${{ needs.init.outputs.metadata }}
ref: ${{ fromJSON(needs.init.outputs.config).checkout.ref }}
repository: ${{ fromJSON(needs.init.outputs.config).checkout.repository }}
package-source: PyPI
package-version: ${{ fromJSON(needs.init.outputs.config).package.version }}
release:
name: 'Release'
needs: [ init, build, website, test-pypi ]
if: ${{ !failure() && fromJSON(needs.init.outputs.config).run.github_release }}
permissions:
contents: write
discussions: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ fromJSON(needs.init.outputs.config).checkout.ref }}
- name: 'Download sdist and wheels artifacts'
uses: actions/download-artifact@v3
with:
name: Distribution Package
path: distribution
- name: 'Download gh-pages artifact'
uses: actions/download-artifact@v3
with:
name: Documentation
path: documentation
- name: 'Zip artifacts'
run: |
mv distribution/*.tar.gz ./
zip -r wheels.zip distribution
zip -r documentation.zip documentation
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ fromJSON(needs.init.outputs.config).release.name }}
tag_name: ${{ fromJSON(needs.init.outputs.config).release.tag_name }}
body: ${{ fromJSON(needs.init.outputs.config).release.body }}
prerelease: ${{ fromJSON(needs.init.outputs.config).release.prerelease }}
discussion_category_name: ${{ fromJSON(needs.init.outputs.config).release.discussion_category_name }}
files: |
wheels.zip
documentation.zip
*.tar.gz