|
| 1 | +# This file is a part of the Globus GitHub Workflows project. |
| 2 | +# https://github.com/globus/workflows |
| 3 | +# Copyright 2021-2026 Globus <support@globus.org> |
| 4 | +# Copyright 2024-2026 Kurt McKee <contactme@kurtmckee.org> |
| 5 | +# SPDX-License-Identifier: MIT |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_call: |
| 9 | + outputs: |
| 10 | + artifact-id: |
| 11 | + description: "The artifact ID that can be subsequently downloaded" |
| 12 | + value: "${{ jobs.build.outputs.artifact-id }}" |
| 13 | + packages-path: |
| 14 | + description: "The path to the Python packages" |
| 15 | + value: "${{ jobs.build.outputs.packages-path }}" |
| 16 | + |
| 17 | +env: |
| 18 | + PYTHON_VERSION: "[[ PYTHON_VERSION ]]" |
| 19 | + UV_VERSION: "[[ UV_VERSION ]]" |
| 20 | + ARTIFACT_NAME: "build-python-package-${{ github.run_id }}" |
| 21 | + PACKAGES_PATH: "./dist" |
| 22 | + BUILD_REQUIREMENTS: | |
| 23 | + [[ include_requirements("build") | indent(4) ]] |
| 24 | +
|
| 25 | +jobs: |
| 26 | + #[#- |
| 27 | + # Halt execution if an attempt is made to run the template directly. |
| 28 | + # This block is enclosed in a Jinja comment and will not be rendered. |
| 29 | + halt: |
| 30 | + name: "Halt" |
| 31 | + runs-on: "ubuntu-slim" |
| 32 | + steps: |
| 33 | + - name: "Halt" |
| 34 | + run: | |
| 35 | + echo "::error::⚠️ Do not run the workflow template directly." |
| 36 | + exit 1 |
| 37 | + #]# |
| 38 | + build: |
| 39 | + #[#- |
| 40 | + # The `needs` key is in a Jinja comment and will not be rendered. |
| 41 | + needs: ["halt"] |
| 42 | + #]# |
| 43 | + name: "Build" |
| 44 | + runs-on: "ubuntu-24.04" |
| 45 | + permissions: |
| 46 | + contents: "read" |
| 47 | + outputs: |
| 48 | + artifact-id: "${{ steps.upload-packages.outputs.artifact-id }}" |
| 49 | + packages-path: "${{ steps.packages-path.outputs.packages-path }}" |
| 50 | + steps: |
| 51 | + - name: "Setup Python" |
| 52 | + uses: "actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405" # v6.2.0 |
| 53 | + with: |
| 54 | + python-version: "${{ env.PYTHON_VERSION }}" |
| 55 | + |
| 56 | + - name: "Install uv" |
| 57 | + uses: "astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867" # v7.1.6 |
| 58 | + with: |
| 59 | + version: "${{ env.UV_VERSION }}" |
| 60 | + enable-cache: "false" |
| 61 | + ignore-empty-workdir: "true" |
| 62 | + |
| 63 | + - name: "Checkout the repository" |
| 64 | + uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2 |
| 65 | + with: |
| 66 | + ref: "${{ github.sha }}" |
| 67 | + persist-credentials: "false" |
| 68 | + |
| 69 | + - name: "Build the package" |
| 70 | + env: |
| 71 | + PIP_DISABLE_PIP_VERSION_CHECK: "1" |
| 72 | + run: | |
| 73 | + REQUIREMENTS_PATH="$(mktemp)" |
| 74 | + echo "${BUILD_REQUIREMENTS}" > "${REQUIREMENTS_PATH}" |
| 75 | +
|
| 76 | + uv run \ |
| 77 | + --no-managed-python \ |
| 78 | + --no-project \ |
| 79 | + --with-requirements="${REQUIREMENTS_PATH}" \ |
| 80 | + --module build --installer=uv --outdir="${PACKAGES_PATH}" |
| 81 | +
|
| 82 | + - name: "Show checksums" |
| 83 | + run: | |
| 84 | + sha256sum "${PACKAGES_PATH}"/* |
| 85 | +
|
| 86 | + - name: "Upload the built packages" |
| 87 | + id: "upload-packages" |
| 88 | + uses: "actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f" # v6.0.0 |
| 89 | + with: |
| 90 | + name: "${{ env.ARTIFACT_NAME }}" |
| 91 | + path: "${{ env.PACKAGES_PATH }}" |
| 92 | + if-no-files-found: "error" |
| 93 | + retention-days: "1" |
| 94 | + overwrite: "false" |
| 95 | + |
| 96 | + - name: "Create packages-path output" |
| 97 | + id: "packages-path" |
| 98 | + run: | |
| 99 | + echo "packages-path=${PACKAGES_PATH}" >> "${GITHUB_OUTPUT}" |
0 commit comments