27
27
type : boolean
28
28
required : true
29
29
description : Enable or disable running pip_audit to check installed packages for vulnerabilities
30
- outputs :
31
- artifacts-sha256 :
32
- value : ${{ jobs.build.outputs.artifacts-sha256 }}
33
- description : The hash of the artifacts
34
30
permissions :
35
31
contents : read
36
32
env :
37
- ARTIFACT_OS : ubuntu-latest # The default OS for release.
38
- ARTIFACT_PYTHON : ' 3.13' # The default Python version for release.
33
+ RELEASE_OS_X86_64 : ubuntu-24.04 # Default OS for x86_64-compatible release artifacts.
34
+ RELEASE_OS_ARM64 : ubuntu-24.04-arm # Default OS for ARM64-compatible release artifacts.
35
+ RELEASE_PYTHON_VERSION : ' 3.13' # Default Python version used for release artifacts.
39
36
40
37
jobs :
41
38
build :
42
39
# Uncomment the following to disable checks and tests for Draft pull requests.
43
40
# if: github.event.pull_request.draft == false
44
- outputs :
45
- artifacts-sha256 : ${{ steps.compute-hash.outputs.artifacts-sha256 }}
46
41
name : Build Python ${{ matrix.python }} on ${{ matrix.os }}
47
42
runs-on : ${{ matrix.os }}
48
43
strategy :
49
44
fail-fast : false
50
45
matrix :
51
46
# It is recommended to pin a Runner version specifically:
52
47
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
53
- # os: [ubuntu-24.04, ubuntu-24.04-arm, macos-latest, windows-latest]
54
- os : [ubuntu-24.04, ubuntu-24.04-arm]
48
+ os : [ubuntu-24.04, ubuntu-24.04-arm, macos-latest, windows-latest]
55
49
python : ['3.10', '3.11', '3.12', '3.13']
56
50
57
51
steps :
58
52
53
+ # Create a GitHub Actions environment variable that maps a matrix.os value to a more descriptive environment
54
+ # value (e.g., ubuntu-x86-64 or ubuntu-arm64).
55
+ - name : Set the architecture label
56
+ run : |
57
+ if [[ "${{ matrix.os }}" == "ubuntu-24.04" ]]; then
58
+ echo "ARCH_ENV=ubuntu-x86-64" >> "$GITHUB_ENV"
59
+ elif [[ "${{ matrix.os }}" == "ubuntu-24.04-arm" ]]; then
60
+ echo "ARCH_ENV=ubuntu-arm64" >> "$GITHUB_ENV"
61
+ else
62
+ echo "ARCH_ENV=unknown" >> "$GITHUB_ENV"
63
+ fi
64
+
65
+ - name : Test the env variable
66
+ run : echo "Architecture-specific env ${{ ARCH_ENV }}"
67
+
59
68
- name : Harden Runner
60
69
uses : step-security/harden-runner@c6295a65d1254861815972266d5933fd6e532bdf # v2.11.1
61
70
with :
@@ -99,24 +108,33 @@ jobs:
99
108
HYPOTHESIS_PROFILE : github
100
109
101
110
# Generate the requirements.txt that contains the hash digests of the dependencies and
102
- # generate the SBOM using CyclonDX SBOM generator.
111
+ # generate the SBOM using CyclonDX SBOM generator for the release Python version and
112
+ # supported release OS targets.
103
113
- name : Generate requirements.txt and SBOM
104
- if : matrix.python == env.ARTIFACT_PYTHON
114
+ if : >
115
+ matrix.python == env.RELEASE_PYTHON_VERSION &&
116
+ (matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
105
117
run : make requirements sbom
106
118
107
119
# Remove the old requirements.txt file (which includes _all_ packages) and generate a
108
- # new one for the package and its actual and required dependencies only.
120
+ # new one for the package and its actual and required dependencies only. Run this step
121
+ # for the release Python version and supported release OS targets only.
109
122
- name : Prune packages and generate required requirements.txt
110
- if : matrix.python == env.ARTIFACT_PYTHON
123
+ if : >
124
+ matrix.python == env.RELEASE_PYTHON_VERSION &&
125
+ (matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
111
126
run : |
112
127
rm requirements.txt
113
128
make prune requirements
114
129
115
130
# Find the paths to the artifact files that will be included in the release, compute
116
131
# the SHA digest for all the release files and encode them using Base64, and export it
117
- # from this job.
132
+ # from this job. Run this step for the release Python version and supported release
133
+ # OS targets only.
118
134
- name : Compute package hash
119
- if : matrix.python == env.ARTIFACT_PYTHON
135
+ if : >
136
+ matrix.python == env.RELEASE_PYTHON_VERSION &&
137
+ (matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
120
138
id : compute-hash
121
139
shell : bash
122
140
run : |
@@ -131,15 +149,28 @@ jobs:
131
149
sha256sum --version
132
150
DIGEST=$(sha256sum "$TARBALL_PATH" "$WHEEL_PATH" "$REQUIREMENTS_PATH" "$SBOM_PATH" "$HTML_DOCS_PATH" "$MARKDOWN_DOCS_PATH" "$BUILD_EPOCH_PATH" | base64 -w0)
133
151
echo "Digest of artifacts is $DIGEST."
134
- echo "artifacts-sha256= $DIGEST" >> "$GITHUB_OUTPUT"
152
+ echo "$DIGEST" > artifacts-sha256-file-${{ ARCH_ENV }}
135
153
136
- # For now only generate artifacts for the specified OS and Python version in env variables.
137
154
# Currently reusable workflows do not support setting strategy property from the caller workflow.
155
+ # Run this step for the release Python version and supported release OS targets only.
138
156
- name : Upload the package artifact for debugging and release
139
- if : matrix.python == env.ARTIFACT_PYTHON
157
+ if : >
158
+ matrix.python == env.RELEASE_PYTHON_VERSION &&
159
+ (matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
140
160
uses : actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
141
161
with :
142
- name : artifact -${{ matrix.os }}-python-${{ matrix.python }}
143
- path : dist
162
+ name : artifacts -${{ ARCH_ENV }}
163
+ path : ./ dist*/
144
164
if-no-files-found : error
145
165
retention-days : 7
166
+
167
+ # Run this step for the release Python version and supported release OS targets only.
168
+ - name : Upload artifacts-sha256
169
+ if : >
170
+ matrix.python == env.RELEASE_PYTHON_VERSION &&
171
+ (matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
172
+ uses : actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
173
+ with :
174
+ name : artifacts-sha256-file-${{ ARCH_ENV }}
175
+ path : artifacts-sha256-file-${{ ARCH_ENV }}
176
+ retention-days : 7
0 commit comments