Repository navigation
108 lines (95 loc) · 2.92 KB
/
Copy pathpython-build-artifacts.yml
File metadata and controls
108 lines (95 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# This workflow is managed by gh actions-lock.
name: Build Artifacts
on:
workflow_call:
inputs:
runner:
description: 'Runner label(s) for the workflow jobs'
type: string
default: 'ubuntu-latest'
registry:
description: ""
required: false
type: string
default: ghcr.io
image-name:
description: ""
required: false
type: string
default: ${{ github.repository }}
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-artifacts:
runs-on: ${{ inputs.runner }}
permissions:
packages: write
contents: write
id-token: write # OIDC token for attestation signing
attestations: write # SBOM + build provenance attestations
env:
SBOM_NAME: sbom.cdx.json
steps:
- name: Checkout
uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
- name: Extract and set version tag
id: version
run: |
# github.ref_name is the tag name (e.g. v1.2.3) on a tag push
VERSION="${GITHUB_REF_NAME}"
# Remove 'v' prefix if present
CLEAN_VERSION="${VERSION#v}"
echo "version=${CLEAN_VERSION}" >> "$GITHUB_OUTPUT"
echo "full_tag=${VERSION}" >> "$GITHUB_OUTPUT"
echo "VERSION=${CLEAN_VERSION}" >> "$GITHUB_ENV"
echo "FULL_TAG=${VERSION}" >> "$GITHUB_ENV"
echo "Release version: ${VERSION}"
echo "Clean version: ${CLEAN_VERSION}"
- name: Set up Python
uses: actions/setup-python@v7.1.0
with:
python-version-file: '.python-version'
cache: pip
cache-dependency-path: |
**/requirements*.txt
**/pyproject.toml
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build wheel setuptools setuptools-scm
- name: Build Python package
run: |
python -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v7.0.2
with:
name: python-package-distributions
path: dist/
- name: Generate SBOM
uses: anchore/sbom-action@v0.24.3
with:
path: .
format: cyclonedx-json
output-file: ${{ env.SBOM_NAME }}
- name: Attest SBOM
uses: actions/attest@v4.2.2
with:
subject-path: dist/*
sbom-path: ${{ env.SBOM_NAME }}
- name: Attest build provenance
uses: actions/attest-build-provenance@v4.2.2
with:
subject-path: dist/*
- name: Create GitHub Release with assets
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ env.FULL_TAG }}
run: |
gh release create "${RELEASE_TAG}" \
--title "${RELEASE_TAG}" \
--generate-notes \
dist/* \
"${SBOM_NAME}"