[DEVOPS-1748] Build pipeline for C++ sdk #21
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build C++ SDK | |
on: | |
push: | |
branches: | |
- main | |
- rc | |
- hotfix-rc | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
generate-schemas: | |
uses: ./.github/workflows/generate_schemas.yml | |
build_rust: | |
uses: ./.github/workflows/build-rust-cross-platform.yml | |
build: | |
name: Build for ${{ matrix.settings.os }} ${{ matrix.settings.target }} | |
needs: | |
- generate-schemas | |
- build_rust | |
runs-on: ${{ matrix.settings.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
settings: | |
- os: macos-12 | |
target: x86_64-apple-darwin | |
# - os: macos-12 # aarch64 is not supported by gh action runners yet | |
# target: aarch64-apple-darwin | |
- os: windows-2022 | |
target: x86_64-pc-windows-msvc | |
- os: ubuntu-22.04 | |
target: x86_64-unknown-linux-gnu | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: install dependencies linux | |
if: runner.os == 'Linux' | |
run: | | |
sudo apt-get install -y nlohmann-json3-dev | |
sudo apt-get install -y libboost-all-dev | |
- name: install dependencies macos | |
if: runner.os == 'macOS' | |
run: | | |
brew install nlohmann-json | |
brew install boost | |
- name: Install libraries for Windows | |
if: runner.os == 'Windows' | |
run: | | |
vcpkg install boost | |
vcpkg install nlohmann-json | |
shell: pwsh | |
# - name: Install libraries for Linux | |
# run: | | |
# conda install -c conda-forge boost | |
# conda install -c conda-forge nlohmann_json | |
# # sudo apt-get update | |
# # sudo apt-get install libboost-all-dev | |
# shell: bash | |
# if: runner.os == 'Linux' | |
- name: Download schemas | |
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 | |
with: | |
name: sdk-schemas-cpp | |
path: languages/cpp/include | |
- name: Download ${{ matrix.settings.target }} files | |
uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 | |
with: | |
name: libbitwarden_c_files-${{ matrix.settings.target }} | |
path: languages/cpp/include | |
- name: Build unix | |
working-directory: languages/cpp | |
if: runner.os == 'macOS' || runner.os == 'Linux' | |
run: | | |
if [[ '${{ runner.os }}' == 'macOS' ]]; then | |
export DNLOHMANN_PATH=/usr/local/opt/nlohmann-json | |
export DBOOST_PATH=/usr/local/opt/boost | |
export DTARGET=include/libbitwarden_c.dylib | |
fi | |
if [[ '${{ runner.os }}' == 'Linux' ]]; then | |
export DNLOHMANN_PATH=/usr/share/doc/nlohmann-json3-dev | |
export DBOOST_PATH=/usr/share/doc/libboost-all-dev | |
export DTARGET=include/libbitwarden_c.so | |
fi | |
mkdir build | |
cd build | |
cmake .. -DNLOHMANN=$DNLOHMANN_PATH -DBOOST=$DBOOST_PATH -DTARGET=$DTARGET | |
cmake --build . | |
- name: Build windows | |
if: runner.os == 'Windows' | |
working-directory: languages/cpp | |
env: | |
BOOST_INCLUDE_DIR: C:\Users\runneradmin\miniconda3\envs\conda-env\Library\include | |
# BOOST_INCLUDE_DIR: C:\Users\runneradmin\miniconda3\envs\conda-env\boost | |
# NLOHMANN_JSON_INCLUDE_DIR: C:\Users\runneradmin\miniconda3\envs\conda-env\nlohmann_json | |
NLOHMANN_JSON_INCLUDE_DIR: C:\Users\runneradmin\miniconda3\envs\conda-env\Library\include | |
run: | | |
mkdir build | |
cd build | |
cmake .. -DNLOHMANN=C:\Users\runneradmin\miniconda3\envs\conda-env\nlohmann_json -DBOOST=C:\Users\runneradmin\miniconda3\envs\conda-env\boost -DTARGET=include/libbitwarden_c.dll | |
cmake --build . | |
- name: Copy artifacts | |
working-directory: languages/cpp/build | |
run: | | |
mkdir artifacts | |
cp libbitwarden_c.* artifacts | |
cp libBitwardenClient.* artifacts | |
- name: Upload C++ package for ${{ matrix.settings.target }} | |
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 | |
with: | |
name: libbitwarden_cpp-${{ matrix.settings.target }} | |
path: languages/cpp/build/artifacts | |
if-no-files-found: error |