-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (146 loc) · 5.18 KB
/
ci.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
name: CI
on:
push:
branches:
- main
tags:
- "*"
pull_request:
jobs:
# Windows MSVC x64 FFI (Windows 7+)
ffi-windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-pc-windows-msvc # 64-bit MSVC (Windows 7+)
steps:
- name: Checkout DNP3
uses: actions/checkout@v4
with:
repository: stepfunc/dnp3
ref: 1.6.0
- name: Install Rust ${{ matrix.rust }}
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Create FFI modules dir
run: mkdir ffi-modules\${{ matrix.target }}
- name: Build FFI
run: cargo build --release -p dnp3-ffi --no-default-features --features tls --target ${{ matrix.target }}
- name: Copy .dll
run: cp .\target\${{ matrix.target }}\release\dnp3_ffi.dll .\ffi-modules\${{ matrix.target }}
- name: Upload FFI modules
uses: actions/upload-artifact@v3
with:
name: ffi-modules
path: ffi-modules
# Cross-compile FFI for Linux platforms
ffi-cross:
env:
# By default, MUSL will not produce a cdylib with dynamic linkage to MUSL LIB C
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-C target-feature=-crt-static"
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS: "-C target-feature=-crt-static"
CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_RUSTFLAGS: "-C target-feature=-crt-static"
strategy:
fail-fast: false
matrix:
target:
- arm-unknown-linux-gnueabihf # ARMv6 Linux, hardfloat (kernel 3.2, glibc 2.17)
- aarch64-unknown-linux-gnu # ARM64 Linux (kernel 4.2, glibc 2.17+)
- x86_64-unknown-linux-gnu # 64-bit Linux (kernel 2.6.32+, glibc 2.11+)
- aarch64-unknown-linux-musl # ARM64 Linux with MUSL
- x86_64-unknown-linux-musl # 64-bit Linux with MUSL
- arm-unknown-linux-musleabihf # ARMv6 Linux with MUSL, hardfloat
runs-on: ubuntu-latest
steps:
- name: Checkout DNP3
uses: actions/checkout@v4
with:
repository: stepfunc/dnp3
ref: 1.6.0
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install Rust Cross
run: cargo install cross
- name: Create FFI modules dir
run: mkdir -p ffi-modules/${{ matrix.target }}
- name: Build FFI
run: cross build --release -p dnp3-ffi --no-default-features --features tls --target ${{ matrix.target }}
- name: Copy .so
run: cp ./target/${{ matrix.target }}/release/libdnp3_ffi.so ./ffi-modules/${{ matrix.target }}
- name: Upload compiled FFI modules
uses: actions/upload-artifact@v3
with:
name: ffi-modules
path: ffi-modules
# Package Nuget
packaging:
needs: [ffi-cross, ffi-windows]
runs-on: ubuntu-latest
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Install Cargo CycloneDx
run: cargo install cargo-cyclonedx
- name: Install custom allow-list tool
run: cargo install --git https://github.com/stepfunc/bom-tools.git
- name: Checkout DNP3
uses: actions/checkout@v4
with:
repository: stepfunc/dnp3
ref: 1.6.0
- name: Download compiled FFI
uses: actions/download-artifact@v3
with:
name: ffi-modules
path: ffi-modules
- name: Create SBOMs
run: |
for dir in ffi-modules/*; do
target=`basename "${dir}"`
cargo cyclonedx -f json --no-default-features --features tls --target $target
mv ./ffi/dnp3-ffi/dnp3-ffi.cdx.json ffi-modules/$target
done
- name: Create FFI third-party-licenses.txt
run: allow-list gen-licenses-dir -l ffi-modules -b dnp3-ffi.cdx.json -c allowed.json > third-party-licenses.txt
- name: Upload third-party-licenses.txt
uses: actions/upload-artifact@v3
with:
name: third-party-licenses
path: third-party-licenses.txt
- name: Package .NET bindings
run: cargo run --bin dnp3-bindings -- --dotnet --package ./ffi-modules -o ./packaging.json -f third-party-licenses.txt
- name: Upload .NET bindings
uses: actions/upload-artifact@v3
with:
name: dotnet-bindings
path: |
ffi/bindings/dotnet/nupkg/dnp3*.nupkg
ffi/bindings/dotnet/nupkg/dnp3*.snupkg
# Create Github Release
release:
needs: [packaging]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
draft: true
files: |
artifacts/dotnet-bindings/dnp3*.nupkg
artifacts/dotnet-bindings/dnp3*.snupkg
artifacts/third-party-licenses/third-party-licenses.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}