|
| 1 | +name: sbom-diff-and-risk-testpypi |
| 2 | +run-name: sbom-diff-and-risk TestPyPI / ${{ github.event_name }} / ${{ github.ref_name }} |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + publish_to_testpypi: |
| 8 | + description: "Upload to TestPyPI using Trusted Publishing. Requires the TestPyPI publisher to be configured first." |
| 9 | + required: true |
| 10 | + default: false |
| 11 | + type: boolean |
| 12 | + push: |
| 13 | + paths: |
| 14 | + - ".github/workflows/sbom-diff-and-risk-testpypi.yml" |
| 15 | + - "tools/sbom-diff-and-risk/PYPI_DESCRIPTION.md" |
| 16 | + - "tools/sbom-diff-and-risk/pyproject.toml" |
| 17 | + - "tools/sbom-diff-and-risk/src/**" |
| 18 | + pull_request: |
| 19 | + paths: |
| 20 | + - ".github/workflows/sbom-diff-and-risk-testpypi.yml" |
| 21 | + - "tools/sbom-diff-and-risk/PYPI_DESCRIPTION.md" |
| 22 | + - "tools/sbom-diff-and-risk/pyproject.toml" |
| 23 | + - "tools/sbom-diff-and-risk/src/**" |
| 24 | + |
| 25 | +permissions: {} |
| 26 | + |
| 27 | +env: |
| 28 | + SBOM_DIFF_RISK_PYTHON_VERSION: "3.11" |
| 29 | + SBOM_DIFF_RISK_DIST_ARTIFACT_NAME: sbom-diff-and-risk-testpypi-dist |
| 30 | + |
| 31 | +jobs: |
| 32 | + build-and-check: |
| 33 | + name: Build and check distributions |
| 34 | + runs-on: ubuntu-latest |
| 35 | + permissions: |
| 36 | + contents: read |
| 37 | + defaults: |
| 38 | + run: |
| 39 | + working-directory: tools/sbom-diff-and-risk |
| 40 | + steps: |
| 41 | + - name: Check out repository |
| 42 | + uses: actions/checkout@v5 |
| 43 | + |
| 44 | + - name: Set up Python |
| 45 | + uses: actions/setup-python@v6 |
| 46 | + with: |
| 47 | + python-version: ${{ env.SBOM_DIFF_RISK_PYTHON_VERSION }} |
| 48 | + |
| 49 | + - name: Upgrade pip |
| 50 | + run: python -m pip install --upgrade pip |
| 51 | + |
| 52 | + - name: Install package build tooling |
| 53 | + run: python -m pip install build twine |
| 54 | + |
| 55 | + - name: Build wheel and source distribution |
| 56 | + run: python -m build |
| 57 | + |
| 58 | + - name: Check distribution metadata |
| 59 | + run: python -m twine check dist/* |
| 60 | + |
| 61 | + - name: Upload checked distribution artifact |
| 62 | + uses: actions/upload-artifact@v4 |
| 63 | + with: |
| 64 | + name: ${{ env.SBOM_DIFF_RISK_DIST_ARTIFACT_NAME }} |
| 65 | + path: | |
| 66 | + tools/sbom-diff-and-risk/dist/*.whl |
| 67 | + tools/sbom-diff-and-risk/dist/*.tar.gz |
| 68 | + if-no-files-found: error |
| 69 | + |
| 70 | + publish-testpypi: |
| 71 | + name: Publish checked distributions to TestPyPI |
| 72 | + if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish_to_testpypi }} |
| 73 | + needs: build-and-check |
| 74 | + runs-on: ubuntu-latest |
| 75 | + environment: |
| 76 | + name: testpypi |
| 77 | + url: https://test.pypi.org/project/sbom-diff-and-risk/ |
| 78 | + permissions: |
| 79 | + id-token: write |
| 80 | + steps: |
| 81 | + - name: Download checked distribution artifact |
| 82 | + uses: actions/download-artifact@v4 |
| 83 | + with: |
| 84 | + name: ${{ env.SBOM_DIFF_RISK_DIST_ARTIFACT_NAME }} |
| 85 | + path: dist |
| 86 | + |
| 87 | + - name: Publish to TestPyPI with Trusted Publishing |
| 88 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 89 | + with: |
| 90 | + repository-url: https://test.pypi.org/legacy/ |
| 91 | + packages-dir: dist/ |
0 commit comments