This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
226 lines (187 loc) · 6.73 KB
/
csharp-bindings-build.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: CSharp Bindings Build
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
actions: read
contents: write
id-token: write
security-events: write
on:
workflow_dispatch:
pull_request:
paths:
- 'packages/rust-core/common/**'
- 'packages/rust-core/charp/**'
- 'packages/rust-core/Cargo.toml'
- 'packages/rust-core/Cargo.lock'
- .github/workflows/csharp-bindings-build.yml
- '.github/workflows/codeql.yml'
push:
branches: [main]
paths:
- 'packages/rust-core/common/**'
- 'packages/rust-core/charp/**'
- 'packages/rust-core/Cargo.toml'
- 'packages/rust-core/Cargo.lock'
- .github/workflows/csharp-bindings-build.yml
- '.github/workflows/codeql.yml'
jobs:
codeql:
name: csharp-bindings-ci-codeql
uses: ./.github/workflows/codeql.yml
with:
language: csharp
working-directory: packages/rust-core/csharp
build:
strategy:
fail-fast: false
matrix:
settings:
- host: macos-latest
target: x86_64-apple-darwin
artifact: libflappy_csharp_bindings.dylib
build: cargo build -r --target x86_64-apple-darwin
- host: macos-latest
target: aarch64-apple-darwin
artifact: libflappy_csharp_bindings.dylib
build: cargo build -r --target aarch64-apple-darwin
- host: ubuntu-latest
target: x86_64-pc-windows-gnu
command: sudo apt-get install -y gcc-mingw-w64-x86-64-win32 && cargo install cargo-xwin
artifact: flappy_csharp_bindings.dll
build: cargo build -r --target x86_64-pc-windows-gnu
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: libflappy_csharp_bindings.so
build: cargo build -r --target x86_64-unknown-linux-gnu
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact: libflappy_csharp_bindings.so
build: cargo build -r --target x86_64-unknown-linux-musl
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact: libflappy_csharp_bindings.so
build: cargo build -r --target aarch64-unknown-linux-gnu
# - host: ubuntu-latest
# target: aarch64-unknown-linux-musl
# artifact: libflappy_csharp_bindings.so
# build: cargo build -r --target aarch64-unknow-linux-musl
name: csharp-bindings-publish-build
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
- name: Run command ${{matrix.settings.command}}
if: ${{matrix.settings.command}}
run: ${{matrix.settings.command}}
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.target }}
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{matrix.settings.target}}
- name: Cache cargo
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
.cargo-cache
target/
key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.host }}
- name: Build
run: ${{ matrix.settings.build }}
shell: bash
working-directory: packages/rust-core/csharp
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: bindings-${{ matrix.settings.target }}
path: '**/${{ matrix.settings.artifact }}'
if-no-files-found: error
package-nuget:
if: ${{ github.ref == 'refs/heads/main' }}
needs: build
runs-on: ubuntu-latest
environment:
name: Nuget
name: csharp-bindings-publish-release
steps:
- uses: actions/checkout@v4
- uses: nuget/setup-nuget@v1
with:
nuget-api-key: ${{ secrets.GITHUB_TOKEN }}
- name: download artifacts
uses: actions/download-artifact@v3
with:
name: bindings-x86_64-apple-darwin
path: ~/artifacts/
- name: download artifacts
uses: actions/download-artifact@v3
with:
name: bindings-aarch64-unknown-linux-gnu
path: ~/artifacts/
- name: download artifacts
uses: actions/download-artifact@v3
with:
name: bindings-aarch64-apple-darwin
path: ~/artifacts/
- name: download artifacts
uses: actions/download-artifact@v3
with:
name: bindings-x86_64-unknown-linux-musl
path: ~/artifacts/
- name: download artifacts
uses: actions/download-artifact@v3
with:
name: bindings-x86_64-unknown-linux-gnu
path: ~/artifacts/
- name: download artifacts
uses: actions/download-artifact@v3
with:
name: bindings-x86_64-pc-windows-gnu
path: ~/artifacts/
- name: make runtimes dir
run: |
find ~/artifacts
dcp() {
local target=$2
local src=$1
mkdir -p ~/nuget/runtimes/$target/native
cp -v ~/artifacts/packages/rust-core/target/$src ~/nuget/runtimes/$target/native/
}
mkdir -p ~/nuget
dcp x86_64-pc-windows-gnu/release/flappy_csharp_bindings.dll win-x64
dcp aarch64-apple-darwin/release/libflappy_csharp_bindings.dylib osx-arm64
dcp x86_64-apple-darwin/release/libflappy_csharp_bindings.dylib osx-x64
dcp x86_64-unknown-linux-gnu/release/libflappy_csharp_bindings.so linux-x64
dcp aarch64-unknown-linux-gnu/release/libflappy_csharp_bindings.so linux-arm64
dcp x86_64-unknown-linux-musl/release/libflappy_csharp_bindings.so linux-musl-x64
#cp packages/rust-core/csharp/tools/Pleisto.Flappy.Native.csproj ~/nuget
tar cvf ~/nuget.tar ~/nuget
gzip -9 ~/nuget.tar
- name: build nupkg
run: |
cd packages/rust-core/csharp/
cp -vr ~/nuget/runtimes ./runtimes
dotnet build -c Release
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: bindings
path: |
packages/csharp/**/*.nupkg
~/nuget.tar.gz
if-no-files-found: error
- name: publish nuget pkg
run: |
find -type f | grep nupkg$ | grep -v 'symbols\.nupkg$' | while read line; do
echo "Pulish: $line"
nuget push $line \
-Source https://api.nuget.org/v3/index.json \
-ApiKey ${{ secrets.NUGET_TOKEN }} \
-SkipDuplicate
done