From 4a49458c61dbadb359cbb6d7a99bb87af1b7ddaf Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sat, 22 Jun 2024 09:50:05 -0400 Subject: [PATCH] build: get the latest dist run id for publishing --- .github/workflows/publish.yml | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4e635df2b..64954accb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,6 +21,26 @@ concurrency: cancel-in-progress: true jobs: + find-run: + name: "Find latest dist run" + runs-on: "ubuntu-latest" + outputs: + run-id: ${{ steps.run-id.outputs.run-id }} + + steps: + - name: "Find latest kit.yml run" + id: runs + uses: octokit/request-action@v2.3.1 + with: + route: GET /repos/nedbat/coveragepy/actions/workflows/kit.yml/runs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Record run id" + id: run-id + run: | + echo "run-id=${{ fromJson(steps.runs.outputs.data).workflow_runs[0].id }}" >> "$GITHUB_OUTPUT" + publish-to-test-pypi: name: "Publish to Test PyPI" if: ${{ github.event.action == 'publish-testpypi' }} @@ -29,15 +49,26 @@ jobs: runs-on: "ubuntu-latest" environment: name: "testpypi" + needs: + - find-run steps: - name: "Download dists" uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 with: + repository: "nedbat/coveragepy" + run-id: ${{needs.find-run.outputs.run-id}} + github-token: ${{ secrets.GITHUB_TOKEN }} pattern: "dist-*" merge-multiple: true path: "dist/" + - name: "What did we get?" + run: | + ls -alR + echo "Number of dists:" + ls -1 dist | wc -l + - name: "Publish dists to Test PyPI" uses: pypa/gh-action-pypi-publish@4bb033805d9e19112d8c697528791ff53f6c2f74 # v1.9.0 with: @@ -53,15 +84,26 @@ jobs: runs-on: "ubuntu-latest" environment: name: "pypi" + needs: + - find-run steps: - name: "Download dists" uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 with: + repository: "nedbat/coveragepy" + run-id: ${{needs.find-run.outputs.run-id}} + github-token: ${{ secrets.GITHUB_TOKEN }} pattern: "dist-*" merge-multiple: true path: "dist/" + - name: "What did we get?" + run: | + ls -alR + echo "Number of dists:" + ls -1 dist | wc -l + - name: "Publish dists to PyPI" uses: pypa/gh-action-pypi-publish@4bb033805d9e19112d8c697528791ff53f6c2f74 # v1.9.0 with: