Skip to content

Update artifact name handling in Python build workflow to use job out… #2

Update artifact name handling in Python build workflow to use job out…

Update artifact name handling in Python build workflow to use job out… #2

Workflow file for this run

on:

Check failure on line 1 in .github/workflows/build.python.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build.python.yml

Invalid workflow file

(Line: 55, Col: 14): Unrecognized function: 'replace'. Located at position 1 within expression: replace(format('{0}-{1}', inputs.working-directory, inputs.artifact-name), '/', '-')
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