Skip to content

Commit 73fa13c

Browse files
authored
Merge pull request #42 from SeaLoong/dev
🐎 ci: rust build
2 parents 6945435 + 6b84d80 commit 73fa13c

File tree

3 files changed

+45
-23
lines changed

3 files changed

+45
-23
lines changed

.github/workflows/rust.yml

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,48 @@
11
name: Rust
2-
3-
on:
4-
push:
5-
branches: [ "master", "dev" ]
6-
pull_request:
7-
branches: [ "master", "dev" ]
8-
2+
on: [push, pull_request]
93
env:
104
CARGO_TERM_COLOR: always
115

126
jobs:
137
build:
14-
15-
runs-on: ubuntu-latest
8+
env:
9+
NPCAP_SDK_URL: "https://npcap.com/dist/npcap-sdk-1.15.zip"
10+
bin_dir: ./tmp_bin
1611
strategy:
1712
matrix:
18-
toolchain:
19-
- nightly
13+
os: [ubuntu-latest, windows-latest]
14+
runs-on: ${{ matrix.os }}
2015
steps:
21-
- uses: actions/checkout@v4
22-
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
23-
- name: Build
24-
run: cargo build --verbose
25-
- name: Build for release
26-
run: cargo build --release --verbose
27-
- name: Run tests
28-
run: cargo test --verbose
16+
- uses: actions/checkout@v4
17+
- name: Set up Rust
18+
uses: dtolnay/rust-toolchain@nightly
19+
- name: Cache Windows dependencies
20+
if: matrix.os == 'windows-latest'
21+
id: cache-windows
22+
uses: actions/cache@v4
23+
with:
24+
key: ${{ env.NPCAP_SDK_URL }}
25+
path: .\Packet.lib
26+
- name: Install Windows dependencies
27+
if: matrix.os == 'windows-latest' && steps.cache-windows.outputs.cache-hit != 'true'
28+
shell: pwsh
29+
run: |
30+
$sdkPath = ".\tmp"
31+
mkdir $sdkPath
32+
Invoke-WebRequest -Uri $env:NPCAP_SDK_URL -OutFile "$sdkPath\npcap-sdk.zip"
33+
Expand-Archive -Path "$sdkPath\npcap-sdk.zip" -DestinationPath $sdkPath
34+
Copy-Item -Path "$sdkPath\Lib\x64\Packet.lib" -Destination .
35+
- name: Build
36+
run: cargo build --verbose
37+
- name: Build for release
38+
run: cargo build --release --verbose
39+
- name: Test
40+
if: matrix.os == 'ubuntu-latest'
41+
run: cargo test --verbose
42+
- name: Cargo Install
43+
run: cargo install --locked --path . --target-dir target --root ${{ env.bin_dir }}
44+
- name: Upload artifact
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: drcom4scut-${{ matrix.os }}
48+
path: ${{ env.bin_dir }}/bin

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ cargo build --release
106106
+ 由于使用了 [**libpnet**](https://crates.io/crates/pnet) ,在Windows下需要安装 *WinPcap**pcap* 才能进行编译,详见[**libpnet**](https://crates.io/crates/pnet)
107107
+ 目前在 Windows/Ubuntu(感谢hyh) 下编译通过,其余环境暂未测试。
108108

109+
### 自动构建
110+
+ 已经为Ubuntu和Windows自动构建了最新版本的drcom4scut,如有需要请从GitHub Action下载。如果文件过期可以自己fork后构建。
109111
### OpenWRT
110112

111113
+ 由于并没有了解这方面,待补充。

0 commit comments

Comments
 (0)