From fcf639ac0c4b27d5ed0e158d2616349398a95a23 Mon Sep 17 00:00:00 2001 From: Nathan Drezner Date: Mon, 10 Feb 2025 15:06:28 -0500 Subject: [PATCH] Seperate reusable workflow into named job --- .github/workflows/publish-to-pypi.yml | 25 ++++++++++++++----------- .github/workflows/release.yml | 23 ++++++++++++----------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index e421af87..c2056947 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -5,6 +5,12 @@ on: types: [published] jobs: + build: + uses: ./.github/workflows/build.yml # Build the package artifacts + with: + python-version: '3.10' + node-version: 'v18.16.0' + pypi-publish: name: Upload release to PyPI runs-on: ubuntu-latest @@ -13,15 +19,12 @@ jobs: permissions: id-token: write # Mandatory for trusted publishing contents: read # Required to access repository files + needs: build # Waits for the build job to finish steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Reuse Build and Validate Workflow - uses: ./.github/workflows/build.yml - with: - python-version: '3.10' - node-version: 'v18.16.0' - - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} + - name: Checkout code + uses: actions/checkout@v4 + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64b5e5af..0c7bfa21 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,27 +1,28 @@ name: Generate release - permissions: contents: read - on: push: tags: - "v*" workflow_dispatch: - jobs: + build: + uses: ./.github/workflows/build.yml # Build the package artifacts + with: + python-version: '3.10' + node-version: 'v18.16.0' + release: runs-on: ubuntu-latest permissions: contents: read + needs: build steps: - - uses: actions/checkout@v4 - - name: Reuse Build and Validate Workflow - uses: ./.github/workflows/build.yml - with: - python-version: '3.10' - node-version: 'v18.16.0' - - uses: ncipollo/release-action@v1 + - name: Checkout repo + uses: actions/checkout@v4 + - name: Upload GitHub Release + uses: ncipollo/release-action@v1 with: artifacts: "dist/*.whl,dist/*.tar.gz" - draft: true + draft: true \ No newline at end of file