-
Notifications
You must be signed in to change notification settings - Fork 50
159 lines (135 loc) · 5.39 KB
/
build-cpp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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-13
target: x86_64-apple-darwin
- os: macos-13
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@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.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: Export GitHub Actions cache environment variables
if: runner.os == 'Windows'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Download schemas
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: sdk-schemas-cpp
path: languages/cpp/include
- name: Download ${{ matrix.settings.target }} files
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: libbitwarden_c_files-${{ matrix.settings.target }}
path: languages/cpp/include
- name: Set permissions to include folder
if: runner.os == 'Windows'
shell: pwsh
run: |
Get-Acl languages/cpp/include/* | Format-List
$path = "./languages/cpp/include"
$name = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
$acl = Get-Acl languages/cpp/include
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule($name,"FullControl","Allow")
$acl.SetAccessRule($accessRule)
$acl | Set-Acl languages/cpp/include
Get-ChildItem -Path "$path" -Recurse -Force | Set-Acl -aclObject $acl -Verbose
Get-Acl languages/cpp/include/* | Format-List
- name: Ensure bitwarden-c is in include folder
working-directory: languages/cpp
shell: bash
run: |
if [[ '${{ runner.os }}' == 'macOS' || '${{ runner.os }}' == 'Linux' ]]; then
ls include/libbitwarden_c.* || { echo "Missing libbitwarden_c.*"; exit 1; }
fi
if [[ '${{ runner.os }}' == 'Windows' ]]; then
ls include/bitwarden_c.dll || { echo "Missing bitwarden_c.dll"; exit 1; }
ls include/bitwarden_c.dll.lib || { echo "Missing bitwarden_c.dll.lib"; exit 1; }
fi
- 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:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
run: |
mkdir build
cd build
$env:DTARGET="include\bitwarden_c.dll.lib"
cmake .. -DTARGET="$env:DTARGET" -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake"
cmake --build . --config Release
shell: pwsh
- name: Copy artifacts
working-directory: languages/cpp/build
shell: bash
run: |
mkdir artifacts
if [[ '${{ runner.os }}' == 'macOS' || '${{ runner.os }}' == 'Linux' ]]; then
cp libbitwarden_c.* artifacts
cp libBitwardenClient.* artifacts
fi
if [[ '${{ runner.os }}' == 'Windows' ]]; then
cp */BitwardenClient.* artifacts
cp ../include/bitwarden_c.{lib,dll.lib,dll} artifacts
fi
- name: Upload C++ package for ${{ matrix.settings.target }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: libbitwarden_cpp-${{ matrix.settings.target }}
path: languages/cpp/build/artifacts
if-no-files-found: error