From 7e9a8ca4cee038b5c3d76d247c2ef29a801abb0e Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Wed, 8 May 2024 16:12:12 -0700 Subject: [PATCH] Build a release asset for FreeBSD This uses the `vmactions/freebsd-vm` GitHub Action to build an asset for FreeBSD alongside the existing assets. See issue 438 for context. The build steps as written produce a working binary on FreeBSD 14.0 x86_64. Note however that the VM used for CI is FreeBSD 13.2; this is because binaries built on a FreeBSD system are forward- but not backward-compatible with other FreeBSD versions. That is, an executable built on 14.0 wouldn't necessarily work on 13.2, but one built on 13.2 will work on 14.0. The choice of 13.2 in particular is because it's the oldest currently supported release. Python 3.11 is used for consistency with other platforms. Unlike other platforms, this build utilizes a virtual environment, simply because it's easier and less error prone. --- .github/workflows/build_assets.yml | 42 ++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_assets.yml b/.github/workflows/build_assets.yml index e541c5f3..8c7808bf 100644 --- a/.github/workflows/build_assets.yml +++ b/.github/workflows/build_assets.yml @@ -130,5 +130,43 @@ jobs: tag: ${{ github.ref }} overwrite: true - - + build_assets_freebsd: + name: Build assets - FreeBSD + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Run in VM + uses: vmactions/freebsd-vm@v1 + with: + release: "13.2" + usesh: true + prepare: | + pkg update + pkg install -y python311 rust + run: | + python3.11 -m venv .venv --upgrade-deps + . .venv/bin/activate + pip install -r requirements.txt + pip install . + python setup.py build + STATICCODECOV_LIB_PATH=$(find build/ -maxdepth 1 -type d -name 'lib.*' -print -quit | xargs -I {} sh -c "find {} -type f -name 'staticcodecov*' print -quit | sed 's|^./||'") + pip install pyinstaller + pyinstaller --add-binary ${STATICCODECOV_LIB_PATH}:. --copy-metadata codecov-cli --hidden-import staticcodecov_languages -F codecov_cli/main.py + cp ./dist/main ./dist/codecovcli_freebsd + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3.1.3 + if: inputs.release == false + with: + path: ./dist/codecovcli_freebsd + - name: Upload Release Asset + if: inputs.release == true + id: upload-release-asset + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./dist/codecovcli_freebsd + asset_name: codecovcli_freebsd + tag: ${{ github.ref }} + overwrite: true