|
| 1 | +# Copyright 2024 Advanced Micro Devices, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +# See https://llvm.org/LICENSE.txt for license information. |
| 5 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | + |
| 7 | +name: Build packages |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_dispatch: |
| 11 | + schedule: |
| 12 | + # Runs at 11:00 AM UTC, which is 3:00 AM PST (UTC-8) |
| 13 | + - cron: '0 11 * * *' |
| 14 | + |
| 15 | +jobs: |
| 16 | + # Note: metadata generation could happen in a separate trigger/schedule |
| 17 | + # workflow. For cross platform builds, it's useful to just generate the |
| 18 | + # metadata on Linux and pass that to later jobs using artifacts. |
| 19 | + setup_metadata: |
| 20 | + runs-on: ubuntu-24.04 |
| 21 | + outputs: |
| 22 | + shark_package_version: ${{ steps.version.outputs.shark_package_version }} |
| 23 | + steps: |
| 24 | + # For now the version is just a calendar date + an automatically |
| 25 | + # incrementing value. We may want different versions for nightly/dev |
| 26 | + # builds and stable releases published to official places like pypi. |
| 27 | + - name: Compute version |
| 28 | + id: version |
| 29 | + run: | |
| 30 | + shark_package_version="$(printf '%(%Y%m%d)T.${{ github.run_number }}')" |
| 31 | + echo "shark_package_version=${shark_package_version}" >> $GITHUB_OUTPUT |
| 32 | + cat << EOF > ./version_info.json |
| 33 | + { |
| 34 | + "package-version": "${shark_package_version}" |
| 35 | + } |
| 36 | + EOF |
| 37 | + cat ./version_info.json |
| 38 | + - name: Upload version_info.json |
| 39 | + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 |
| 40 | + with: |
| 41 | + name: version_info |
| 42 | + path: version_info.json |
| 43 | + |
| 44 | + build_packages: |
| 45 | + name: "${{ matrix.package }} :: ${{ matrix.platform }} :: ${{ matrix.python-version }}" |
| 46 | + runs-on: ${{ matrix.runs-on }} |
| 47 | + needs: [setup_metadata] |
| 48 | + strategy: |
| 49 | + fail-fast: false |
| 50 | + matrix: |
| 51 | + include: |
| 52 | + # Ubuntu packages. |
| 53 | + - runs-on: ubuntu-24.04 |
| 54 | + platform: linux-x86_64 |
| 55 | + package: shortfin |
| 56 | + python-version: cp312-cp312 |
| 57 | + - runs-on: ubuntu-24.04 |
| 58 | + platform: linux-x86_64 |
| 59 | + package: shortfin |
| 60 | + python-version: cp313-cp313 |
| 61 | + - runs-on: ubuntu-24.04 |
| 62 | + platform: linux-x86_64 |
| 63 | + package: shortfin |
| 64 | + python-version: cp313-cp313t |
| 65 | + |
| 66 | + # TODO(#130): macOS platform |
| 67 | + # TODO(#130): Windows platform |
| 68 | + # TODO(#130): sharktank packages |
| 69 | + |
| 70 | + steps: |
| 71 | + - name: Checkout repository |
| 72 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 73 | + with: |
| 74 | + path: "c" # Windows can hit path length limits, so use a short path. |
| 75 | + submodules: false |
| 76 | + |
| 77 | + - name: Download version_info.json |
| 78 | + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
| 79 | + with: |
| 80 | + name: version_info |
| 81 | + path: ./c/shortfin/ |
| 82 | + merge-multiple: true |
| 83 | + |
| 84 | + - name: Build shortfin (Linux x86_64, ${{ matrix.python-version }}) |
| 85 | + if: "matrix.package == 'shortfin' && matrix.platform == 'linux-x86_64'" |
| 86 | + env: |
| 87 | + OUTPUT_DIR: "${{ github.workspace }}/bindist" |
| 88 | + OVERRIDE_PYTHON_VERSIONS: "${{ matrix.python-version }}" |
| 89 | + run: | |
| 90 | + [ -e ./bindist/* ] && rm ./bindist/* |
| 91 | + ./c/shortfin/build_tools/build_linux_package.sh |
| 92 | +
|
| 93 | + - name: Upload python wheels |
| 94 | + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 |
| 95 | + with: |
| 96 | + if-no-files-found: error |
| 97 | + name: snapshot-${{ matrix.package }}-${{ matrix.platform }}-${{ matrix.python-version }} |
| 98 | + path: bindist |
| 99 | + |
| 100 | + - name: Release python wheels |
| 101 | + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 |
| 102 | + with: |
| 103 | + artifacts: bindist/*.whl |
| 104 | + token: "${{ secrets.GITHUB_TOKEN }}" |
| 105 | + tag: "dev-wheels" |
| 106 | + name: "dev-wheels" |
| 107 | + body: "Automatic snapshot release of SHARK-Platform python wheels." |
| 108 | + removeArtifacts: false |
| 109 | + allowUpdates: true |
| 110 | + replacesArtifacts: true |
| 111 | + makeLatest: false |
0 commit comments