Skip to content

build artifact

build artifact #2

name: build artifact
on:
workflow_dispatch:
workflow_call:
outputs:
artifact-url:
description: "URL to the uploaded artifact"
value: ${{ jobs.build_artifacts.outputs.artifact-url }}
artifact-id:
description: "ID of the uploaded artifact"
value: ${{ jobs.build_artifacts.outputs.artifact-id }}
package-version:
description: "Version of the package"
value: ${{ jobs.build_artifacts.outputs.package-version }}
artifact-name:
description: "Name of the artifact"
value: ${{ jobs.build_artifacts.outputs.artifact-name }}
jobs:
build_artifacts:
runs-on: ubuntu-latest
permissions: # Job-level permissions configuration starts here
contents: write # 'write' access to repository contents
actions: read
id-token: write
attestations: write
steps:
- name: Set up Python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5
with:
python-version: 3.12
- name: install poetry
uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b # v1
with:
version: 1.8.3 # pin the version as they keep changing their APIs
virtualenvs-create: false
virtualenvs-in-project: false
- name: check out code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 1
- name: Install dependencies
run: |
python -m venv venv
. venv/bin/activate
poetry install --with dev --no-interaction --sync
python -c "import os; print(os.environ['VIRTUAL_ENV'])"
- name: Build
id: Build
run: |
version=$(poetry version | awk '{print $2}')
echo "version is $version"
echo "version=$version" >> "$GITHUB_OUTPUT"
artifact_name="dist-$version"
echo "artifact_name is $artifact_name"
echo "artifact_name=$artifact_name" >> "$GITHUB_OUTPUT"
poetry build
- name: attest artifacts
id: attest-artifacts
uses: actions/attest-build-provenance@v1
with:
subject-path: 'dist/*'
# dont do this yet - PEP 740 support just isnt ready
# - name: copy attestation to dist dir
# run: |
# cp ${{ steps.attest-artifacts.outputs.bundle-path }} $GITHUB_WORKSPACE/dist/attestation.jsonl
- name: Upload build artifact
id: upload-artifact
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4
with:
compression-level: 0 # no compression
if-no-files-found: error
name: ${{ steps.Build.outputs.artifact_name }}
path: dist/*
- name: publish release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*,${{ steps.attest-artifacts.outputs.bundle-path }}"
tag: ${{ steps.Build.outputs.version }}
allowUpdates: true
artifactErrorsFailBuild: true
outputs:
artifact-url: ${{ steps.upload-artifact.outputs.artifact-url }}
artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
package-version: ${{ steps.Build.outputs.version }}
artifact-name: ${{ steps.Build.outputs.artifact_name }}