|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + |
| 10 | + release: |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 18 | + python-version: [3.9] |
| 19 | + |
| 20 | + include: |
| 21 | + - os: ubuntu-latest |
| 22 | + cmake_generator: "Unix Makefiles" |
| 23 | + - os: macos-latest |
| 24 | + cmake_generator: "Unix Makefiles" |
| 25 | + - os: windows-latest |
| 26 | + cmake_generator: "MinGW Makefiles" |
| 27 | + |
| 28 | + defaults: |
| 29 | + run: |
| 30 | + # Required when using an activated conda environment in steps |
| 31 | + # See https://github.com/conda-incubator/setup-miniconda#IMPORTANT |
| 32 | + shell: bash -l {0} |
| 33 | + |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + lfs: false |
| 38 | + submodules: recursive |
| 39 | + |
| 40 | + - name: Set up conda environment for testing |
| 41 | + uses: conda-incubator/setup-miniconda@v3 |
| 42 | + with: |
| 43 | + auto-update-conda: true |
| 44 | + python-version: ${{ matrix.python-version }} |
| 45 | + activate-environment: osqp-test |
| 46 | + environment-file: tests/testenv.yml |
| 47 | + auto-activate-base: false |
| 48 | + |
| 49 | + - name: Setup Envvars |
| 50 | + run: | |
| 51 | + echo "OSQP_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV |
| 52 | + echo "OSQP_NAME=osqp-${GITHUB_REF/refs\/tags\//}-${{ runner.os }}" >> $GITHUB_ENV |
| 53 | +
|
| 54 | + # ----------------- |
| 55 | + # OS-specific setup |
| 56 | + # ----------------- |
| 57 | + - name: Setup (Linux) |
| 58 | + if: runner.os == 'Linux' |
| 59 | + run: | |
| 60 | + echo "LD_LIBRARY_PATH=$CONDA_PREFIX/lib" >> $GITHUB_ENV |
| 61 | + conda install -c conda-forge libstdcxx-ng |
| 62 | +
|
| 63 | + - name: Setup (macOS) |
| 64 | + if: runner.os == 'macOS' |
| 65 | + # Newer versions of MacOS effectively block DYLD_LIBRARY_PATH being set (System Integrity Protection) |
| 66 | + # Explicitly setting RPATH using `install_name_tool -add_rpath $CONDA_PREFIX/lib ./build/out/osqp_tester` |
| 67 | + # doesn't work either. |
| 68 | + # Here we get around it by using a standard non-root location for .dylib files as a soft link |
| 69 | + run: | |
| 70 | + echo "DYLD_LIBRARY_PATH=$CONDA_PREFIX/lib" >> $GITHUB_ENV |
| 71 | + ln -s $CONDA_PREFIX/lib ~/lib |
| 72 | +
|
| 73 | + - name: Setup (Windows) |
| 74 | + if: runner.os == 'Windows' |
| 75 | + run: | |
| 76 | + echo "$CONDA_PREFIX/Library/bin" >> $GITHUB_PATH |
| 77 | + # ----------------- |
| 78 | + |
| 79 | + # Fetching mkl from the anaconda channel instead of defaults gives us the MKL runtime dynamic libraries |
| 80 | + # as well (mkl_rt.<dll/so>), required during the runtime testing steps. |
| 81 | + # MKL on Anaconda 2021.* seems to have inexplicably renamed mkl_rt.dll to mkl_rt.1.dll, so we insist on |
| 82 | + # a version earlier than 2021 |
| 83 | + - name: Install python dependencies |
| 84 | + run: | |
| 85 | + conda install -c anaconda "mkl<2021" |
| 86 | + conda info |
| 87 | + conda list |
| 88 | +
|
| 89 | + - name: Build |
| 90 | + run: | |
| 91 | + cmake -DOSQP_VERSION=$OSQP_VERSION -G "${{ matrix.cmake_generator }}" -S . -B build |
| 92 | + cmake --build build |
| 93 | +
|
| 94 | + # useful for inspecting the OSQP version information |
| 95 | + - name: OSQP Demo |
| 96 | + run: | |
| 97 | + ./build/out/osqp_demo |
| 98 | +
|
| 99 | + - name: Generate binary release file |
| 100 | + run: | |
| 101 | + mkdir -p $OSQP_NAME/lib $OSQP_NAME/include |
| 102 | + cp LICENSE $OSQP_NAME/ |
| 103 | + cp include/public/*.h $OSQP_NAME/include/ |
| 104 | + cp build/out/libosqp.* $OSQP_NAME/lib/ |
| 105 | + cd $OSQP_NAME && tar -czvf ../$OSQP_NAME.tar.gz * |
| 106 | +
|
| 107 | + - name: Release binary |
| 108 | + uses: softprops/action-gh-release@v2 |
| 109 | + with: |
| 110 | + files: ${{env.OSQP_NAME}}.tar.gz |
| 111 | + |
| 112 | + - name: Generate source release file |
| 113 | + if: ${{ runner.os == 'Linux' }} |
| 114 | + run: | |
| 115 | + git ls-files --recurse-submodules | grep -v ^site/ | tar czf osqp-${{env.OSQP_VERSION}}-src.tar.gz --files-from - |
| 116 | +
|
| 117 | + - name: Release source |
| 118 | + if: ${{ runner.os == 'Linux' }} |
| 119 | + uses: softprops/action-gh-release@v2 |
| 120 | + with: |
| 121 | + files: osqp-${{env.OSQP_VERSION}}-src.tar.gz |
0 commit comments