|
| 1 | +# This workflow builds and publishes codecov-cli on release creation. |
| 2 | +# sentry-prevent-cli is built and published separately (managed by craft) |
| 3 | +name: Build and publish codecov-cli |
| 4 | + |
| 5 | +on: |
| 6 | + push: #temp |
| 7 | + # release: |
| 8 | + # types: |
| 9 | + # - created |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + build_for_pypi: |
| 16 | + permissions: |
| 17 | + contents: read |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + persist-credentials: false |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + run: pip install uv |
| 26 | + |
| 27 | + - name: Build codecov-cli sdist and bdist |
| 28 | + run: | |
| 29 | + cd codecov-cli |
| 30 | + uv build |
| 31 | +
|
| 32 | + - name: Build prevent-cli sdist and bdist |
| 33 | + run: | |
| 34 | + cd prevent-cli |
| 35 | + uv build |
| 36 | +
|
| 37 | + - name: Upload codecov-cli artifacts |
| 38 | + uses: actions/upload-artifact@v4 |
| 39 | + with: |
| 40 | + name: codecov-cli-pypi |
| 41 | + path: ./codecov-cli/dist/* |
| 42 | + |
| 43 | + - name: Upload prevent-cli artifacts |
| 44 | + uses: actions/upload-artifact@v4 |
| 45 | + with: |
| 46 | + name: prevent-cli-pypi |
| 47 | + path: ./prevent-cli/dist/* |
| 48 | + |
| 49 | + # publish_to_pypi: |
| 50 | + # needs: build_for_pypi |
| 51 | + # permissions: |
| 52 | + # id-token: write # This is required for OIDC |
| 53 | + # runs-on: ubuntu-latest |
| 54 | + # environment: |
| 55 | + # name: pypi |
| 56 | + # url: https://pypi.org/p/codecov-cli |
| 57 | + # steps: |
| 58 | + # - name: Download build artifacts |
| 59 | + # uses: actions/download-artifact@v4 |
| 60 | + # with: |
| 61 | + # name: pypi |
| 62 | + # path: codecov-cli/dist |
| 63 | + # |
| 64 | + # - name: Publish package to PyPi |
| 65 | + # uses: pypa/gh-action-pypi-publish@release/v1 |
| 66 | + # with: |
| 67 | + # verbose: true |
| 68 | + # packages-dir: codecov-cli/dist |
| 69 | + |
| 70 | + build_assets: |
| 71 | + name: Build ${{ matrix.os }} binaries |
| 72 | + runs-on: ${{ matrix.os }} |
| 73 | + strategy: |
| 74 | + fail-fast: true |
| 75 | + matrix: |
| 76 | + include: |
| 77 | + - os: macos-latest |
| 78 | + TARGET: macos |
| 79 | + CMD_BUILD: > |
| 80 | + uv run pyinstaller --target-arch universal2 -F codecov_cli/main.py && |
| 81 | + mv dist/main dist/codecovcli_macos && |
| 82 | + uv run pyinstaller --target-arch universal2 -F prevent_cli/main.py && |
| 83 | + mv dist/main dist/sentry-prevent-cli_macos |
| 84 | + OUT_FILE_SUFFIX: _macos |
| 85 | + ASSET_MIME: application/octet-stream |
| 86 | + |
| 87 | + - os: windows-latest |
| 88 | + TARGET: windows |
| 89 | + CMD_BUILD: > |
| 90 | + uv run pyinstaller -F codecov_cli\main.py && |
| 91 | + Move-Item -Path ".\dist\main.exe" -Destination ".\dist\codecovcli_windows.exe" && |
| 92 | + uv run pyinstaller -F prevent-cli\main.py && |
| 93 | + Move-Item -Path ".\dist\main.exe" -Destination ".\dist\sentry-prevent-cli_windows.exe" |
| 94 | + OUT_FILE_SUFFIX: _windows.exe |
| 95 | + ASSET_MIME: application/vnd.microsoft.portable-executable |
| 96 | + |
| 97 | + steps: |
| 98 | + - uses: actions/checkout@v4 |
| 99 | + |
| 100 | + - name: Set up Python 3.9 |
| 101 | + uses: actions/setup-python@v3 |
| 102 | + with: |
| 103 | + python-version: "3.9" |
| 104 | + |
| 105 | + - name: Install dependencies |
| 106 | + run: | |
| 107 | + pip install uv |
| 108 | + cd prevent-cli # codecov-cli is a dependency of prevent-cli |
| 109 | + # Need to build pyyaml and ijson from sdists to get universal2 macos build to work |
| 110 | + uv sync --no-binary-package pyyaml --no-binary-package ijson |
| 111 | + uv add --dev pyinstaller |
| 112 | +
|
| 113 | + - name: Build with pyinstaller for ${{matrix.TARGET}} |
| 114 | + run: cd codecov-cli && ${{matrix.CMD_BUILD}} |
| 115 | + |
| 116 | + - name: Upload codecovcli binary for ${{matrix.TARGET}} |
| 117 | + uses: actions/upload-artifact@v4 |
| 118 | + with: |
| 119 | + name: codecovcli${{matrix.OUT_FILE_SUFFIX}} |
| 120 | + path: ./codecov-cli/dist/codecovcli${{matrix.OUT_FILE_SUFFIX}} |
| 121 | + |
| 122 | + - name: Upload sentry-prevent-cli binary for ${{matrix.TARGET}} |
| 123 | + uses: actions/upload-artifact@v4 |
| 124 | + with: |
| 125 | + name: sentry-prevent-cli${{matrix.OUT_FILE_SUFFIX}} |
| 126 | + path: ./prevent-cli/dist/sentry-prevent-cli${{matrix.OUT_FILE_SUFFIX}} |
| 127 | + |
| 128 | + build_linux_assets: |
| 129 | + name: Build ${{ matrix.distro_name }}_${{ matrix.arch }} binary |
| 130 | + runs-on: ${{ matrix.runs-on }} |
| 131 | + strategy: |
| 132 | + matrix: |
| 133 | + include: |
| 134 | + - distro: "alpine:3.14" # alpine 3.14 needed for musl 1.2.2/python 3.9 compatibility |
| 135 | + arch: arm64 |
| 136 | + distro_name: alpine |
| 137 | + runs-on: ubuntu-24.04-arm |
| 138 | + - distro: "alpine:3.14" |
| 139 | + arch: x86_64 |
| 140 | + distro_name: alpine |
| 141 | + runs-on: ubuntu-24.04 |
| 142 | + - distro: "ubuntu:20.04" # ubuntu 20.04 needed for glibc 2.31/python 3.9 compatibility |
| 143 | + arch: arm64 |
| 144 | + distro_name: linux |
| 145 | + runs-on: ubuntu-24.04-arm |
| 146 | + - distro: "ubuntu:20.04" |
| 147 | + distro_name: linux |
| 148 | + arch: x86_64 |
| 149 | + runs-on: ubuntu-24.04 |
| 150 | + |
| 151 | + steps: |
| 152 | + - uses: actions/checkout@v4 |
| 153 | + |
| 154 | + - name: Run in Docker |
| 155 | + run: | |
| 156 | + docker run \ |
| 157 | + --rm \ |
| 158 | + -v $(pwd):/${{ github.workspace }} \ |
| 159 | + -w ${{ github.workspace }} \ |
| 160 | + --platform linux/${{ matrix.arch }} \ |
| 161 | + ${{ matrix.distro }} \ |
| 162 | + ./codecov-cli/scripts/build_${{ matrix.distro_name }}.sh ${{ matrix.distro_name }}_${{ matrix.arch }} |
| 163 | +
|
| 164 | + - name: Upload codecovcli binary for ${{matrix.distro_name}}_${{ matrix.arch}} |
| 165 | + uses: actions/upload-artifact@v4 |
| 166 | + with: |
| 167 | + name: codecovcli_${{ matrix.distro_name }}_${{ matrix.arch }} |
| 168 | + path: ./codecov-cli/dist/codecovcli_* |
| 169 | + |
| 170 | + - name: Upload sentry-prevent-cli binary for ${{matrix.distro_name}}_${{ matrix.arch}} |
| 171 | + uses: actions/upload-artifact@v4 |
| 172 | + with: |
| 173 | + name: sentry-prevent-cli_${{ matrix.distro_name }}_${{ matrix.arch }} |
| 174 | + path: ./prevent-cli/dist/sentry-prevent-cli_* |
| 175 | + |
| 176 | + # - name: Get auth token |
| 177 | + # id: token |
| 178 | + # uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 |
| 179 | + # with: |
| 180 | + # app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }} |
| 181 | + # private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }} |
| 182 | + # |
| 183 | + # - name: Upload Release Asset |
| 184 | + # id: upload-release-asset |
| 185 | + # uses: svenstaro/upload-release-action@v2 |
| 186 | + # with: |
| 187 | + # repo_token: ${{ steps.token.outputs.token }} |
| 188 | + # file_glob: true |
| 189 | + # file: ./codecov-cli/dist/codecovcli_* |
| 190 | + # tag: ${{ github.ref }} |
| 191 | + # overwrite: true |
| 192 | + |
| 193 | + # publish_release: |
| 194 | + # name: Publish release |
| 195 | + # needs: [build_assets, build_linux_assets, build_for_pypi, publish_to_pypi] |
| 196 | + # runs-on: ubuntu-latest |
| 197 | + # permissions: |
| 198 | + # contents: "read" |
| 199 | + # id-token: "write" |
| 200 | + # steps: |
| 201 | + # - id: "auth" |
| 202 | + # name: "Authenticate to Google Cloud" |
| 203 | + # uses: "google-github-actions/auth@v1.0.0" |
| 204 | + # with: |
| 205 | + # create_credentials_file: "true" |
| 206 | + # workload_identity_provider: ${{ secrets.CODECOV_GCP_WIDP }} |
| 207 | + # service_account: ${{ secrets.CODECOV_GCP_WIDSA }} |
| 208 | + # |
| 209 | + # # Publish the release tag to a Pub/Sub topic |
| 210 | + # - name: Publish a message to a Pub/Sub topic |
| 211 | + # env: |
| 212 | + # CLOUDSDK_CORE_PROJECT: ${{ secrets.GCLOUD_UPLOADER_PROJECT_ID }} |
| 213 | + # run: | |
| 214 | + # gcloud pubsub topics publish ${{ secrets.GCLOUD_UPLOADER_PUBSUB_TOPIC }} --message '{"release":"'"${{ github.ref_name }}"'", "latest":true}' |
0 commit comments