|
| 1 | +name: Build Compiled Assets |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + release: |
| 7 | + type: boolean |
| 8 | + default: false |
| 9 | + description: "Attach artifacts to a release" |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + build_assets: |
| 16 | + name: Build packages - ${{ matrix.os }} |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + permissions: |
| 19 | + contents: write # needed for svenstaro/upload-release-action when inputs.release == true |
| 20 | + strategy: |
| 21 | + fail-fast: true |
| 22 | + matrix: |
| 23 | + include: |
| 24 | + - os: macos-latest |
| 25 | + TARGET: macos |
| 26 | + CMD_BUILD: > |
| 27 | + uv run pyinstaller --target-arch universal2 -F codecov_cli/main.py && |
| 28 | + mv dist/main dist/codecovcli_macos && |
| 29 | + lipo -archs dist/codecovcli_macos | grep 'x86_64 arm64' |
| 30 | + OUT_FILE_NAME: codecovcli_macos |
| 31 | + |
| 32 | + - os: ubuntu-22.04 |
| 33 | + TARGET: ubuntu |
| 34 | + CMD_BUILD: > |
| 35 | + uv run pyinstaller -F codecov_cli/main.py && |
| 36 | + cp ./dist/main ./dist/codecovcli_linux |
| 37 | + OUT_FILE_NAME: codecovcli_linux |
| 38 | + |
| 39 | + - os: windows-latest |
| 40 | + TARGET: windows |
| 41 | + CMD_BUILD: > |
| 42 | + uv run pyinstaller -F .\codecov_cli\main.py && |
| 43 | + Copy-Item -Path ".\dist\main.exe" -Destination ".\dist\codecovcli_windows.exe" |
| 44 | + OUT_FILE_NAME: codecovcli_windows.exe |
| 45 | + |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 48 | + |
| 49 | + - name: Set up Python 3.11 |
| 50 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 |
| 51 | + with: |
| 52 | + python-version: "3.11" |
| 53 | + |
| 54 | + - name: Install uv and dependencies |
| 55 | + run: | |
| 56 | + pip install uv |
| 57 | + # Need to build pyyaml and ijson from sdists to get universal2 macos build to work |
| 58 | + uv sync --no-binary-package pyyaml --no-binary-package ijson |
| 59 | +
|
| 60 | + - name: Build with pyinstaller for ${{ matrix.TARGET }} |
| 61 | + run: ${{ matrix.CMD_BUILD }} |
| 62 | + |
| 63 | + - name: Upload a Build Artifact |
| 64 | + if: inputs.release == false |
| 65 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 66 | + with: |
| 67 | + name: ${{ matrix.OUT_FILE_NAME }} |
| 68 | + path: ./dist/${{ matrix.OUT_FILE_NAME }} |
| 69 | + |
| 70 | + - name: Upload Release Asset |
| 71 | + if: inputs.release == true |
| 72 | + uses: svenstaro/upload-release-action@81c65b7cd4de9b2570615ce3aad67a41de5b1a13 # v2.11.2 |
| 73 | + with: |
| 74 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 75 | + file: ./dist/${{ matrix.OUT_FILE_NAME }} |
| 76 | + asset_name: ${{ matrix.OUT_FILE_NAME }} |
| 77 | + tag: ${{ github.ref }} |
| 78 | + overwrite: true |
| 79 | + |
| 80 | + build_assets_alpine_arm: |
| 81 | + name: Build assets - Alpine and ARM |
| 82 | + runs-on: ${{ matrix.runs-on }} |
| 83 | + permissions: |
| 84 | + contents: write # needed for svenstaro/upload-release-action when inputs.release == true |
| 85 | + strategy: |
| 86 | + matrix: |
| 87 | + include: |
| 88 | + - distro: "alpine:3.14" |
| 89 | + arch: arm64 |
| 90 | + distro_name: alpine |
| 91 | + runs-on: ubuntu-24.04-arm |
| 92 | + - distro: "alpine:3.14" |
| 93 | + arch: x86_64 |
| 94 | + distro_name: alpine |
| 95 | + runs-on: ubuntu-24.04 |
| 96 | + - distro: "ubuntu:20.04" |
| 97 | + arch: arm64 |
| 98 | + distro_name: linux |
| 99 | + runs-on: ubuntu-24.04-arm |
| 100 | + |
| 101 | + steps: |
| 102 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 103 | + |
| 104 | + - name: Run in Docker |
| 105 | + run: | |
| 106 | + docker run \ |
| 107 | + --rm \ |
| 108 | + -v $(pwd):/${{ github.workspace }} \ |
| 109 | + -w ${{ github.workspace }} \ |
| 110 | + --platform linux/${{ matrix.arch }} \ |
| 111 | + ${{ matrix.distro }} \ |
| 112 | + ./scripts/build_${{ matrix.distro_name }}.sh ${{ matrix.distro_name }}_${{ matrix.arch }} |
| 113 | +
|
| 114 | + - name: Upload a Build Artifact |
| 115 | + if: inputs.release == false |
| 116 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 117 | + with: |
| 118 | + name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }} |
| 119 | + path: ./dist/codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }} |
| 120 | + |
| 121 | + - name: Upload Release Asset |
| 122 | + if: inputs.release == true |
| 123 | + uses: svenstaro/upload-release-action@81c65b7cd4de9b2570615ce3aad67a41de5b1a13 # v2.11.2 |
| 124 | + with: |
| 125 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 126 | + file: ./dist/codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }} |
| 127 | + asset_name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }} |
| 128 | + tag: ${{ github.ref }} |
| 129 | + overwrite: true |
0 commit comments