1
- # Copyright (c) 2022 - 2023 , Oracle and/or its affiliates. All rights reserved.
1
+ # Copyright (c) 2022 - 2025 , Oracle and/or its affiliates. All rights reserved.
2
2
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
3
3
4
4
# This is a trusted builder implemented as a reusable workflow that can be called by other
25
25
name : Build the package
26
26
on :
27
27
workflow_call :
28
- outputs :
29
- artifacts-sha256 :
30
- description : The hash of the artifacts
31
- value : ${{ jobs.build.outputs.artifacts-sha256 }}
32
28
permissions :
33
29
contents : read
34
30
env :
35
- ARTIFACT_OS : ubuntu-latest # The default OS for release.
36
- ARTIFACT_PYTHON : ' 3.11' # The default Python version for release.
37
- PACKAGE_PATH : src/macaron # The relative Python package path to the repo.
31
+ RELEASE_OS_X86_64 : ubuntu-24.04 # Default OS for x86_64-compatible release artifacts.
32
+ RELEASE_OS_ARM64 : ubuntu-24.04-arm # Default OS for ARM64-compatible release artifacts.
33
+ RELEASE_PYTHON_VERSION : ' 3.11' # Default Python version used for release artifacts.
34
+ PACKAGE_PATH : src/macaron # The relative Python package path to the repo.
38
35
39
36
jobs :
40
37
build :
41
- outputs :
42
- artifacts-sha256 : ${{ steps.compute-hash.outputs.artifacts-sha256 }}
43
38
name : Build Macaron
44
39
runs-on : ${{ matrix.os }}
45
40
strategy :
46
41
fail-fast : false
47
42
matrix :
48
43
# It is recommended to pin a Runner version specifically:
49
44
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
50
- os : [ubuntu-latest ]
45
+ os : [ubuntu-24.04, ubuntu-24.04-arm ]
51
46
python : ['3.11']
47
+
48
+ outputs :
49
+ arch-env : ${{ steps.set-arch-env.outputs.arch_env }}
50
+
52
51
steps :
53
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 : Determine architecture label
56
+ id : set-arch-env
57
+ shell : bash
58
+ run : |
59
+ if [[ "${{ matrix.os }}" == "ubuntu-24.04" ]]; then
60
+ echo "arch_env=ubuntu-x86-64" >> "$GITHUB_OUTPUT"
61
+ elif [[ "${{ matrix.os }}" == "ubuntu-24.04-arm" ]]; then
62
+ echo "arch_env=ubuntu-arm64" >> "$GITHUB_OUTPUT"
63
+ else
64
+ echo "arch_env=unknown" >> "$GITHUB_OUTPUT"
65
+ fi
66
+
67
+ - name : Test the env variable
68
+ run : echo "Architecture-specific value ${{ steps.set-arch-env.outputs.arch_env }}"
69
+
54
70
- name : Check out repository
55
71
uses : actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
56
72
with :
@@ -91,24 +107,33 @@ jobs:
91
107
GITHUB_TOKEN : ${{ github.token }}
92
108
93
109
# Generate the requirements.txt that contains the hash digests of the dependencies and
94
- # generate the SBOM using CycloneDX SBOM generator.
110
+ # generate the SBOM using CyclonDX SBOM generator for the release Python version and
111
+ # supported release OS targets.
95
112
- name : Generate requirements.txt and SBOM
96
- if : matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
113
+ if : >
114
+ matrix.python == env.RELEASE_PYTHON_VERSION &&
115
+ (matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
97
116
run : make requirements sbom
98
117
99
118
# Remove the old requirements.txt file (which includes _all_ packages) and generate a
100
- # new one for the package and its actual and required dependencies only.
119
+ # new one for the package and its actual and required dependencies only. Run this step
120
+ # for the release Python version and supported release OS targets only.
101
121
- name : Prune packages and generate required requirements.txt
102
- if : matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
122
+ if : >
123
+ matrix.python == env.RELEASE_PYTHON_VERSION &&
124
+ (matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
103
125
run : |
104
126
rm requirements.txt
105
127
make prune requirements
106
128
107
129
# Find the paths to the artifact files that will be included in the release, compute
108
- # the SHA digest for all the release files and encode them using Base64, and export it
109
- # from this job.
130
+ # the SHA digest for all the release files and encode them using Base64, and upload it
131
+ # from this job. Run this step for the release Python version and supported release
132
+ # OS targets only.
110
133
- name : Compute package hash
111
- if : matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
134
+ if : >
135
+ matrix.python == env.RELEASE_PYTHON_VERSION &&
136
+ (matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
112
137
id : compute-hash
113
138
shell : bash
114
139
run : |
@@ -123,19 +148,32 @@ jobs:
123
148
DIGEST=$(sha256sum "$TARBALL_PATH" "$WHEEL_PATH" "$REQUIREMENTS_PATH" "$SBOM_PATH" \
124
149
"$SBOM_GO_PATH" "$HTML_DOCS_PATH" "$BUILD_EPOCH_PATH" | base64 -w0)
125
150
echo "Digest of artifacts is $DIGEST."
126
- echo "artifacts-sha256= $DIGEST" >> "$GITHUB_OUTPUT"
151
+ echo "$DIGEST" > artifacts-sha256-file-${{ steps.set-arch-env.outputs.arch_env }}
127
152
128
153
# For now only generate artifacts for the specified OS and Python version in env variables.
129
154
# Currently reusable workflows do not support setting strategy property from the caller workflow.
130
155
- name : Upload the package artifact for debugging and release
131
- if : matrix.os == env.ARTIFACT_OS && matrix.python == env.ARTIFACT_PYTHON
156
+ if : >
157
+ matrix.python == env.RELEASE_PYTHON_VERSION &&
158
+ (matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
132
159
uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
133
160
with :
134
- name : artifact -${{ matrix.os }}-python-${{ matrix.python }}
135
- path : dist
161
+ name : artifacts -${{ steps.set-arch-env.outputs.arch_env }}
162
+ path : ./ dist*/
136
163
if-no-files-found : error
137
164
retention-days : 7
138
165
166
+ # Run this step for the release Python version and supported release OS targets only.
167
+ - name : Upload artifacts sha256
168
+ if : >
169
+ matrix.python == env.RELEASE_PYTHON_VERSION &&
170
+ (matrix.os == env.RELEASE_OS_X86_64 || matrix.os == env.RELEASE_OS_ARM64)
171
+ uses : actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
172
+ with :
173
+ name : artifacts-sha256-file-${{ steps.set-arch-env.outputs.arch_env }}
174
+ path : artifacts-sha256-file-${{ steps.set-arch-env.outputs.arch_env }}
175
+ retention-days : 7
176
+
139
177
# This job calls the reusable workflow _build_docker.yaml to build and test
140
178
# the Docker image. Note that the built image is not pushed to ghcr.io here.
141
179
build_docker_image :
@@ -145,7 +183,6 @@ jobs:
145
183
packages : read
146
184
uses : ./.github/workflows/_build_docker.yaml
147
185
with :
148
- artifact-sha256 : ${{ needs.build.outputs.artifacts-sha256 }}
149
- # TODO: use ${{ env.ARTIFACT_OS }} and ${{ env.ARTIFACT_PYTHON }}
186
+ # TODO: use ${{ env.RELEASE_OS_X86_64 }}
150
187
# when this issue is addressed: https://github.com/actions/runner/issues/2394.
151
- artifact-name : artifact- ubuntu-latest-python-3.11
188
+ artifact-architecture : ubuntu-x86-64
0 commit comments