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.
22# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33
44# This is a trusted builder implemented as a reusable workflow that can be called by other
2525name : Build the package
2626on :
2727 workflow_call :
28- outputs :
29- artifacts-sha256 :
30- description : The hash of the artifacts
31- value : ${{ jobs.build.outputs.artifacts-sha256 }}
3228permissions :
3329 contents : read
3430env :
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.
3835
3936jobs :
4037 build :
41- outputs :
42- artifacts-sha256 : ${{ steps.compute-hash.outputs.artifacts-sha256 }}
4338 name : Build Macaron
4439 runs-on : ${{ matrix.os }}
4540 strategy :
4641 fail-fast : false
4742 matrix :
4843 # It is recommended to pin a Runner version specifically:
4944 # 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 ]
5146 python : ['3.11']
47+
48+ outputs :
49+ arch-env : ${{ steps.set-arch-env.outputs.arch_env }}
50+
5251 steps :
5352
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+
5470 - name : Check out repository
5571 uses : actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
5672 with :
@@ -91,24 +107,33 @@ jobs:
91107 GITHUB_TOKEN : ${{ github.token }}
92108
93109 # 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.
95112 - 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)
97116 run : make requirements sbom
98117
99118 # 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.
101121 - 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)
103125 run : |
104126 rm requirements.txt
105127 make prune requirements
106128
107129 # 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.
110133 - 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)
112137 id : compute-hash
113138 shell : bash
114139 run : |
@@ -123,19 +148,32 @@ jobs:
123148 DIGEST=$(sha256sum "$TARBALL_PATH" "$WHEEL_PATH" "$REQUIREMENTS_PATH" "$SBOM_PATH" \
124149 "$SBOM_GO_PATH" "$HTML_DOCS_PATH" "$BUILD_EPOCH_PATH" | base64 -w0)
125150 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 }}
127152
128153 # For now only generate artifacts for the specified OS and Python version in env variables.
129154 # Currently reusable workflows do not support setting strategy property from the caller workflow.
130155 - 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)
132159 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
133160 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*/
136163 if-no-files-found : error
137164 retention-days : 7
138165
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+
139177 # This job calls the reusable workflow _build_docker.yaml to build and test
140178 # the Docker image. Note that the built image is not pushed to ghcr.io here.
141179 build_docker_image :
@@ -145,7 +183,6 @@ jobs:
145183 packages : read
146184 uses : ./.github/workflows/_build_docker.yaml
147185 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 }}
150187 # 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