Skip to content

Merge pull request #2 from stepfunc/prepare/1.6.0 #33

Merge pull request #2 from stepfunc/prepare/1.6.0

Merge pull request #2 from stepfunc/prepare/1.6.0 #33

Workflow file for this run

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 }}