Skip to content

Commit 4bf4c91

Browse files
authored
feat: support archive v4 (#350)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 31940ff commit 4bf4c91

File tree

7 files changed

+70
-40
lines changed

7 files changed

+70
-40
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ for family, grp in itertools.groupby(collected.checks.items(), key=lambda x: x[1
345345
- [`GH101`](https://learn.scientific-python.org/development/guides/gha-basic#GH101): Has nice names
346346
- [`GH102`](https://learn.scientific-python.org/development/guides/gha-basic#GH102): Auto-cancel on repeated PRs
347347
- [`GH103`](https://learn.scientific-python.org/development/guides/gha-basic#GH103): At least one workflow with manual dispatch trigger
348+
- [`GH104`](https://learn.scientific-python.org/development/guides/gha-wheel#GH104): Use unique names for upload-artifact
348349
- [`GH200`](https://learn.scientific-python.org/development/guides/gha-basic#GH200): Maintained by Dependabot
349350
- [`GH210`](https://learn.scientific-python.org/development/guides/gha-basic#GH210): Maintains the GitHub action versions with Dependabot
350351
- [`GH211`](https://learn.scientific-python.org/development/guides/gha-basic#GH211): Do not pin core actions as major versions

docs/pages/guides/gha_basic.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ this action later; specifically, may want to use
660660

661661
```yaml
662662
- name: Upload artifact
663-
uses: actions/upload-pages-artifact@v2
663+
uses: actions/upload-pages-artifact@v3
664664
```
665665

666666
This actions defaults to uploading `_site`, but you can give any `with: path:`
@@ -682,7 +682,7 @@ deploy:
682682
steps:
683683
- name: Deploy to GitHub Pages
684684
id: deployment
685-
uses: actions/deploy-pages@v3
685+
uses: actions/deploy-pages@v4
686686
```
687687

688688
{% endraw %}

docs/pages/guides/gha_pure.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ dist:
7777
- name: Build SDist and wheel
7878
run: pipx run build
7979
80-
- uses: actions/upload-artifact@v3
80+
- uses: actions/upload-artifact@v4
8181
with:
8282
name: Packages
8383
path: dist/*
@@ -125,7 +125,7 @@ later in the upload action for the release job, as well).
125125
> ```yaml
126126
> steps:
127127
> - uses: actions/checkout@v4
128-
> - uses: hynek/build-and-inspect-python-package@v1
128+
> - uses: hynek/build-and-inspect-python-package@v2
129129
> ```
130130
>
131131
> The artifact it produces is named `Packages`, so that's what you need to use
@@ -146,7 +146,7 @@ publish:
146146
runs-on: ubuntu-latest
147147
if: github.event_name == 'release' && github.event.action == 'published'
148148
steps:
149-
- uses: actions/download-artifact@v3
149+
- uses: actions/download-artifact@v4
150150
with:
151151
name: Packages
152152
path: dist
@@ -172,7 +172,7 @@ publish:
172172
runs-on: ubuntu-latest
173173
if: github.event_name == 'release' && github.event.action == 'published'
174174
steps:
175-
- uses: actions/download-artifact@v3
175+
- uses: actions/download-artifact@v4
176176
with:
177177
name: Packages
178178
path: dist
@@ -223,7 +223,7 @@ jobs:
223223
with:
224224
fetch-depth: 0
225225
226-
- uses: hynek/build-and-inspect-python-package@v1
226+
- uses: hynek/build-and-inspect-python-package@v2
227227
228228
publish:
229229
needs: [dist]
@@ -234,7 +234,7 @@ jobs:
234234
if: github.event_name == 'release' && github.event.action == 'published'
235235
236236
steps:
237-
- uses: actions/download-artifact@v3
237+
- uses: actions/download-artifact@v4
238238
with:
239239
name: Packages
240240
path: dist
@@ -269,15 +269,15 @@ jobs:
269269
with:
270270
fetch-depth: 0
271271
272-
- uses: hynek/build-and-inspect-python-package@v1
272+
- uses: hynek/build-and-inspect-python-package@v2
273273
274274
publish:
275275
needs: [dist]
276276
runs-on: ubuntu-latest
277277
if: github.event_name == 'release' && github.event.action == 'published'
278278
279279
steps:
280-
- uses: actions/download-artifact@v3
280+
- uses: actions/download-artifact@v4
281281
with:
282282
name: Packages
283283
path: dist

docs/pages/guides/gha_wheels.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ make_sdist:
9292
- name: Build SDist
9393
run: pipx run build --sdist
9494
95-
- uses: actions/upload-artifact@v3
95+
- uses: actions/upload-artifact@v4
9696
with:
97-
name: SDist
97+
name: cibw-sdist
9898
path: dist/*.tar.gz
9999
```
100100

@@ -125,9 +125,9 @@ build_wheels:
125125
- uses: pypa/[email protected]
126126
127127
- name: Upload wheels
128-
uses: actions/upload-artifact@v3
128+
uses: actions/upload-artifact@v4
129129
with:
130-
name: Wheels-${{ matrix.os }}
130+
name: cibw-wheels-${{ matrix.os }}
131131
path: wheelhouse/*.whl
132132
```
133133

@@ -177,14 +177,11 @@ upload_all:
177177
runs-on: ubuntu-latest
178178
if: github.event_name == 'release' && github.event.action == 'published'
179179
steps:
180-
- uses: actions/download-artifact@v3
180+
- uses: actions/download-artifact@v4
181181
with:
182-
path: all
183-
184-
- name: Merge files
185-
run: |
186-
mkdir dist
187-
mv all/*/* dist
182+
pattern: cibw-*
183+
path: dist
184+
merge-multiple: true
188185
189186
- uses: pypa/gh-action-pypi-publish@release/v1
190187
```
@@ -207,14 +204,11 @@ upload_all:
207204
runs-on: ubuntu-latest
208205
if: github.event_name == 'release' && github.event.action == 'published'
209206
steps:
210-
- uses: actions/download-artifact@v3
207+
- uses: actions/download-artifact@v4
211208
with:
212-
path: all
213-
214-
- name: Merge files
215-
run: |
216-
mkdir dist
217-
mv all/*/* dist
209+
pattern: cibw-*
210+
path: dist
211+
merge-multiple: true
218212
219213
- uses: pypa/gh-action-pypi-publish@release/v1
220214
with:

src/sp_repo_review/checks/github.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,44 @@ def check(workflows: dict[str, Any]) -> bool:
107107
return any("workflow_dispatch" in w.get(True, {}) for w in workflows.values())
108108

109109

110+
class GH104(GitHub):
111+
"Use unique names for upload-artifact"
112+
113+
requires = {"GH100"}
114+
url = mk_url("gha-wheel")
115+
116+
@staticmethod
117+
def check(workflows: dict[str, Any]) -> bool:
118+
"""
119+
Multiple upload-artifact usages _must_ have unique names to be
120+
compatible with `v4` (which no longer merge artifacts, but instead
121+
errors out). The most general solution is:
122+
123+
```yaml
124+
- uses: actions/upload-artifact@v4
125+
with:
126+
name: prefix-${{ github.job }}-${{ strategy.job-index }}
127+
128+
- uses: actions/download-artifact@v4
129+
with:
130+
pattern: prefix-*
131+
merge-multiple: true
132+
```
133+
"""
134+
135+
for workflow in workflows.values():
136+
names = [
137+
step.get("with", {}).get("name", "")
138+
for job in workflow.get("jobs", {}).values()
139+
for step in job.get("steps", [])
140+
if step.get("uses", "").startswith("actions/upload-artifact")
141+
]
142+
names = [n for n in names if "${{" not in n]
143+
if len(names) != len(set(names)):
144+
return False
145+
return True
146+
147+
110148
class GH200(GitHub):
111149
"Maintained by Dependabot"
112150

{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type!='compiled' %}cd.yml{% endif %}

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
fetch-depth: 0
2929

30-
- uses: hynek/build-and-inspect-python-package@v1
30+
- uses: hynek/build-and-inspect-python-package@v2
3131

3232
publish:
3333
needs: [dist]
@@ -39,7 +39,7 @@ jobs:
3939
if: github.event_name == 'release' && github.event.action == 'published'
4040

4141
steps:
42-
- uses: actions/download-artifact@v3
42+
- uses: actions/download-artifact@v4
4343
with:
4444
name: Packages
4545
path: dist

{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type=='compiled' %}cd.yml{% endif %}

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
- name: Build SDist
2626
run: pipx run build --sdist
2727

28-
- uses: actions/upload-artifact@v3
28+
- uses: actions/upload-artifact@v4
2929
with:
30-
name: SDist
30+
name: cibw-sdist
3131
path: dist/*.tar.gz
3232

3333
build_wheels:
@@ -46,9 +46,9 @@ jobs:
4646
- uses: pypa/[email protected]
4747

4848
- name: Upload wheels
49-
uses: actions/upload-artifact@v3
49+
uses: actions/upload-artifact@v4
5050
with:
51-
name: Wheel-{% raw %}${{ matrix.os }}{% endraw %}
51+
name: cibw-wheels-{% raw %}${{ matrix.os }}-${{ strategy.job-index }}{% endraw %}
5252
path: wheelhouse/*.whl
5353

5454
upload_all:
@@ -60,14 +60,11 @@ jobs:
6060
if: github.event_name == 'release' && github.event.action == 'published'
6161

6262
steps:
63-
- uses: actions/download-artifact@v3
63+
- uses: actions/download-artifact@v4
6464
with:
65+
pattern: cibw-*
6566
path: dist
66-
67-
- name: Merge files
68-
run: |
69-
mkdir dist
70-
mv all/*/* dist
67+
merge-multiple: true
7168

7269
- uses: pypa/gh-action-pypi-publish@release/v1
7370
with:

0 commit comments

Comments
 (0)