-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (115 loc) · 4.2 KB
/
build-native.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
name: Build Worker Native Libs
on:
workflow_dispatch:
inputs:
version:
type: string
required: true
description: Version number (package)
permissions:
packages: write
contents: read
jobs:
build-macos:
name: Build (macOS Universal)
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: chmod +x ./native/nuget/scripts/build_macos.sh && ./native/nuget/scripts/build_macos.sh
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: macos
path: native/src/target/universal-release/*.dylib
build-windows:
name: Build (Windows ${{ matrix.arch }})
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
arch: [x86_64, aarch64]
steps:
- uses: actions/checkout@v3
- name: Prepare Build Target
run: rustup target add ${{ matrix.arch }}-pc-windows-msvc
- name: Build
run: cargo build --release --target ${{ matrix.arch }}-pc-windows-msvc
working-directory: native/src
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: windows-${{ matrix.arch }}
path: native/src/target/${{ matrix.arch }}-pc-windows-msvc/release/*.dll
build-linux:
name: Build (${{ matrix.vendor }}/Linux ${{ matrix.arch }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [ x86_64, aarch64 ]
vendor: [ gnu, musl ]
env:
RUST_TARGET: ${{ matrix.arch }}-unknown-linux-${{ matrix.vendor }}
steps:
- uses: actions/checkout@v3
# cross-rs is needed if the arch being built isn't the same as the host (linux only)
- name: Install Cross
if: matrix.arch != 'x86_64'
run: cargo install cross --git https://github.com/cross-rs/cross
# also need to ensure the target is installed otherwise musl will fail.
- name: Install Build Target (Non-GNU)
if: matrix.arch == 'x86_64' && matrix.vendor != 'gnu'
run: rustup target install $RUST_TARGET
- name: Build
run: ${{ matrix.arch == 'x86_64' && 'cargo' || 'cross' }} build --release --target $RUST_TARGET
working-directory: native/src
env:
# musl-specific workaround to get files to build - see https://github.com/rust-lang/cargo/issues/7154#issuecomment-561947609
RUSTFLAGS: ${{ matrix.vendor == 'musl' && '-C target-feature=-crt-static' || '' }}
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: linux-${{ matrix.vendor }}-${{ matrix.arch }}
path: native/src/target/${{ env.RUST_TARGET }}/release/*.so
publish-package:
name: Publish Package
runs-on: ubuntu-latest
needs:
- build-windows
- build-macos
- build-linux
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: macos
path: native/nuget/runtimes/osx/native
- uses: actions/download-artifact@v3
with:
name: windows-x86_64
path: native/nuget/runtimes/win-x64/native
- uses: actions/download-artifact@v3
with:
name: windows-aarch64
path: native/nuget/runtimes/win-arm64/native
- uses: actions/download-artifact@v3
with:
name: linux-musl-x86_64
path: native/nuget/runtimes/linux-musl-x64/native
- uses: actions/download-artifact@v3
with:
name: linux-musl-aarch64
path: native/nuget/runtimes/linux-musl-arm64/native
- uses: actions/download-artifact@v3
with:
name: linux-gnu-x86_64
path: native/nuget/runtimes/linux-x64/native
- uses: actions/download-artifact@v3
with:
name: linux-gnu-aarch64
path: native/nuget/runtimes/linux-arm64/native
- name: Build Package
run: dotnet pack -c Release -p:Version=${{ github.event.inputs.version }} -o ./packages native/nuget
- name: Publish Package
run: dotnet nuget push -s https://nuget.pkg.github.com/dragonfruitnetwork/index.json -k ${{ github.token }} ./packages/*.nupkg