|
| 1 | +# This file is a part of Kurt McKee's GitHub Workflows project. |
| 2 | +# https://github.com/kurtmckee/github-workflows |
| 3 | +# Copyright 2024-2026 Kurt McKee <contactme@kurtmckee.org> |
| 4 | +# SPDX-License-Identifier: MIT |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_call: |
| 8 | + outputs: |
| 9 | + artifact-id: |
| 10 | + description: "The artifact ID that can be subsequently downloaded" |
| 11 | + value: "${{ jobs.build.outputs.artifact-id }}" |
| 12 | + packages-path: |
| 13 | + description: "The path to the Python packages" |
| 14 | + value: "${{ jobs.build.outputs.packages-path }}" |
| 15 | + |
| 16 | +env: |
| 17 | + PYTHON_VERSION: "3.13" |
| 18 | + ARTIFACT_NAME: "build-python-package-${{ github.run_id }}" |
| 19 | + PACKAGES_PATH: "./dist" |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + name: "Build" |
| 24 | + runs-on: "ubuntu-24.04" |
| 25 | + permissions: |
| 26 | + contents: "read" |
| 27 | + outputs: |
| 28 | + artifact-id: "${{ steps.upload-packages.outputs.artifact-id }}" |
| 29 | + packages-path: "${{ steps.packages-path.outputs.packages-path }}" |
| 30 | + steps: |
| 31 | + - name: "Setup Python" |
| 32 | + uses: "actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548" # v6.1.0 |
| 33 | + with: |
| 34 | + python-version: "${{ env.PYTHON_VERSION }}" |
| 35 | + |
| 36 | + - name: "Checkout the repository" |
| 37 | + uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2 |
| 38 | + with: |
| 39 | + ref: "${{ github.sha }}" |
| 40 | + persist-credentials: "false" |
| 41 | + |
| 42 | + - name: "Build the package" |
| 43 | + env: |
| 44 | + PIP_DISABLE_PIP_VERSION_CHECK: "1" |
| 45 | + run: | |
| 46 | + python -m pip install build |
| 47 | + python -m build --outdir "${PACKAGES_PATH}" |
| 48 | +
|
| 49 | + - name: "Show checksums" |
| 50 | + run: | |
| 51 | + sha256sum "${PACKAGES_PATH}"/* |
| 52 | +
|
| 53 | + - name: "Upload the built packages" |
| 54 | + id: "upload-packages" |
| 55 | + uses: "actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f" # v6.0.0 |
| 56 | + with: |
| 57 | + name: "${{ env.ARTIFACT_NAME }}" |
| 58 | + path: "${{ env.PACKAGES_PATH }}" |
| 59 | + if-no-files-found: "error" |
| 60 | + retention-days: "1" |
| 61 | + overwrite: "false" |
| 62 | + |
| 63 | + - name: "Create packages-path output" |
| 64 | + id: "packages-path" |
| 65 | + run: | |
| 66 | + echo "packages-path=${PACKAGES_PATH}" >> "${GITHUB_OUTPUT}" |
0 commit comments