-
Notifications
You must be signed in to change notification settings - Fork 0
211 lines (176 loc) · 6.89 KB
/
Copy pathrelease.yml
File metadata and controls
211 lines (176 loc) · 6.89 KB
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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: rust_network_discovery_tool
asset_name: rust_network_discovery_tool-linux-x86_64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: rust_network_discovery_tool
asset_name: rust_network_discovery_tool-macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: rust_network_discovery_tool
asset_name: rust_network_discovery_tool-macos-aarch64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: rust_network_discovery_tool.exe
asset_name: rust_network_discovery_tool-windows-x86_64.exe
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libpcap-dev
- name: Install Windows dependencies
if: matrix.os == 'windows-latest'
shell: powershell
run: |
# Download and install Npcap SDK for building
Invoke-WebRequest -Uri "https://npcap.com/dist/npcap-sdk-1.13.zip" -OutFile "npcap-sdk.zip"
Expand-Archive -Path "npcap-sdk.zip" -DestinationPath "C:\npcap-sdk-temp"
# Move all SDK contents to C:\npcap-sdk
Write-Host "Moving SDK contents to C:\npcap-sdk"
Move-Item -Path "C:\npcap-sdk-temp" -Destination "C:\npcap-sdk"
# Verify Packet.lib exists and set LIB environment variable
if (Test-Path "C:\npcap-sdk\Lib\x64\Packet.lib") {
Write-Host "SUCCESS: Found Packet.lib at C:\npcap-sdk\Lib\x64\Packet.lib"
Add-Content -Path $env:GITHUB_ENV -Value "LIB=C:\npcap-sdk\Lib\x64"
} else {
Write-Host "ERROR: Cannot find Packet.lib"
Get-ChildItem "C:\npcap-sdk" -Recurse | Where-Object { $_.Name -like "*.lib" } | Format-Table FullName
exit 1
}
- name: Build release binary
run: |
cargo build --release --target ${{ matrix.target }}
- name: Strip binary (Linux and macOS)
if: matrix.os != 'windows-latest'
run: |
strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release archives
run: |
cd artifacts
for dir in */; do
name=${dir%/}
if [[ $name == *windows* ]]; then
cd "$dir"
zip "../${name}.zip" *
cd ..
else
cd "$dir"
tar czf "../${name}.tar.gz" *
cd ..
fi
done
- name: Generate checksums
run: |
cd artifacts
sha256sum *.tar.gz *.zip > SHA256SUMS
- name: Extract release notes
id: extract_notes
run: |
# Extract version from tag
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: false
generate_release_notes: true
files: |
artifacts/*.tar.gz
artifacts/*.zip
artifacts/SHA256SUMS
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-readme:
name: Update README with latest release
needs: release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update README
run: |
VERSION=${GITHUB_REF#refs/tags/}
# Create installation section
cat > installation.md << 'EOF'
## Installation
### Pre-built Binaries
Download the latest release for your platform:
- **macOS (Apple Silicon)**: [rust_network_discovery_tool-macos-aarch64.tar.gz](https://github.com/${{ github.repository }}/releases/latest/download/rust_network_discovery_tool-macos-aarch64.tar.gz)
- **macOS (Intel)**: [rust_network_discovery_tool-macos-x86_64.tar.gz](https://github.com/${{ github.repository }}/releases/latest/download/rust_network_discovery_tool-macos-x86_64.tar.gz)
- **Linux**: [rust_network_discovery_tool-linux-x86_64.tar.gz](https://github.com/${{ github.repository }}/releases/latest/download/rust_network_discovery_tool-linux-x86_64.tar.gz)
- **Windows**: [rust_network_discovery_tool-windows-x86_64.zip](https://github.com/${{ github.repository }}/releases/latest/download/rust_network_discovery_tool-windows-x86_64.zip)
#### macOS/Linux Installation
```bash
# Download and extract (adjust filename for your platform)
tar -xzf rust_network_discovery_tool-macos-aarch64.tar.gz
# Make executable
chmod +x rust_network_discovery_tool
# Move to PATH (optional)
sudo mv rust_network_discovery_tool /usr/local/bin/
# Run with sudo (required for packet capture)
sudo rust_network_discovery_tool
```
#### Windows Installation
1. Download and extract the ZIP file
2. Install [Npcap](https://npcap.com/#download) (required for packet capture)
3. Run as Administrator (required for packet capture)
### Build from Source
EOF
# Insert after the Features section
sed -i '/## Features/r installation.md' README.md
rm installation.md
- name: Commit README changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
git diff --staged --quiet || git commit -m "docs: update README with release ${GITHUB_REF#refs/tags/}"
git push origin HEAD:main