Skip to content

Commit 4a49458

Browse files
committed
build: get the latest dist run id for publishing
1 parent fb15efa commit 4a49458

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/publish.yml

+42
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@ concurrency:
2121
cancel-in-progress: true
2222

2323
jobs:
24+
find-run:
25+
name: "Find latest dist run"
26+
runs-on: "ubuntu-latest"
27+
outputs:
28+
run-id: ${{ steps.run-id.outputs.run-id }}
29+
30+
steps:
31+
- name: "Find latest kit.yml run"
32+
id: runs
33+
uses: octokit/[email protected]
34+
with:
35+
route: GET /repos/nedbat/coveragepy/actions/workflows/kit.yml/runs
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: "Record run id"
40+
id: run-id
41+
run: |
42+
echo "run-id=${{ fromJson(steps.runs.outputs.data).workflow_runs[0].id }}" >> "$GITHUB_OUTPUT"
43+
2444
publish-to-test-pypi:
2545
name: "Publish to Test PyPI"
2646
if: ${{ github.event.action == 'publish-testpypi' }}
@@ -29,15 +49,26 @@ jobs:
2949
runs-on: "ubuntu-latest"
3050
environment:
3151
name: "testpypi"
52+
needs:
53+
- find-run
3254

3355
steps:
3456
- name: "Download dists"
3557
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
3658
with:
59+
repository: "nedbat/coveragepy"
60+
run-id: ${{needs.find-run.outputs.run-id}}
61+
github-token: ${{ secrets.GITHUB_TOKEN }}
3762
pattern: "dist-*"
3863
merge-multiple: true
3964
path: "dist/"
4065

66+
- name: "What did we get?"
67+
run: |
68+
ls -alR
69+
echo "Number of dists:"
70+
ls -1 dist | wc -l
71+
4172
- name: "Publish dists to Test PyPI"
4273
uses: pypa/gh-action-pypi-publish@4bb033805d9e19112d8c697528791ff53f6c2f74 # v1.9.0
4374
with:
@@ -53,15 +84,26 @@ jobs:
5384
runs-on: "ubuntu-latest"
5485
environment:
5586
name: "pypi"
87+
needs:
88+
- find-run
5689

5790
steps:
5891
- name: "Download dists"
5992
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
6093
with:
94+
repository: "nedbat/coveragepy"
95+
run-id: ${{needs.find-run.outputs.run-id}}
96+
github-token: ${{ secrets.GITHUB_TOKEN }}
6197
pattern: "dist-*"
6298
merge-multiple: true
6399
path: "dist/"
64100

101+
- name: "What did we get?"
102+
run: |
103+
ls -alR
104+
echo "Number of dists:"
105+
ls -1 dist | wc -l
106+
65107
- name: "Publish dists to PyPI"
66108
uses: pypa/gh-action-pypi-publish@4bb033805d9e19112d8c697528791ff53f6c2f74 # v1.9.0
67109
with:

0 commit comments

Comments
 (0)