Update artifact name handling in Python build workflow to use job out… #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | ||
|
Check failure on line 1 in .github/workflows/build.python.yml
|
||
| workflow_call: | ||
| inputs: | ||
| python_version: | ||
| required: false | ||
| type: string | ||
| description: "What Python version to use." | ||
| default: "3.13" | ||
| working-directory: | ||
| required: false | ||
| type: string | ||
| default: "." | ||
| git-sha: | ||
| required: false | ||
| type: string | ||
| default: ${{ github.event.pull_request.head.sha || github.sha }} | ||
| outputs: | ||
| artifact-name: | ||
| description: The name of the artifact generated by the build | ||
| value: ${{ jobs.build.outputs.artifact-name }} | ||
| jobs: | ||
| build: | ||
| name: Build Python | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| artifact-name: ${{ steps.artifact-name.outputs.artifact-name }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: '0' # Fetch all history for all branches and tags (for branches) | ||
| ref: ${{ inputs.git-sha }} | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v5 | ||
| with: | ||
| enable-cache: true | ||
| cache-dependency-glob: "${{ inputs.working-directory }}/uv.lock" | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ inputs.python_version }} | ||
| - name: Install dependencies | ||
| working-directory: ${{ inputs.working-directory }} | ||
| run: | | ||
| uv build | ||
| uv pip install dist/*.whl --target ./out | ||
| find ./out/ -name "__pycache__" -type d -exec rm -rf {} \; | ||
| - name: Determine artifact name | ||
| id: artifact-name | ||
| run: echo "artifact-name=${{ replace(format('{0}-{1}', inputs.working-directory, inputs.artifact-name), '/', '-') }}" >> $GITHUB_OUTPUT | ||
| - name: Store build as Artifact | ||
| uses: actions/upload-artifact@v4 | ||
| id: upload-artifact | ||
| with: | ||
| name: ${{ steps.artifact-name.outputs.artifact-name }} | ||
| path: ${{ inputs.working-directory }}/out | ||
| retention-days: 5 | ||