|
1 | | -name: Build masscan for Windows |
| 1 | +name: Build and Release masscan for Windows (x64) |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: [ master ] |
6 | | - workflow_dispatch: |
| 6 | + tags: |
| 7 | + - 'v*' # triggers a release on tags like v1.0.0 |
| 8 | + workflow_dispatch: # manual trigger from the Actions tab |
7 | 9 |
|
8 | 10 | jobs: |
9 | | - build: |
| 11 | + build-and-release: |
10 | 12 | runs-on: windows-latest |
11 | | - defaults: |
12 | | - run: |
13 | | - shell: cmd |
| 13 | + |
14 | 14 | steps: |
15 | | - - uses: actions/checkout@v4 |
| 15 | + # 1. Checkout your source code |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + # 2. Download and extract the Npcap SDK (WinPcap-compatible) |
| 20 | + - name: Setup Npcap SDK |
| 21 | + run: | |
| 22 | + curl -L -o npcap-sdk.zip https://npcap.com/dist/npcap-sdk-1.13.zip |
| 23 | + mkdir npcap-sdk |
| 24 | + tar -xf npcap-sdk.zip -C npcap-sdk |
| 25 | + echo "PCAP_DIR=$env:GITHUB_WORKSPACE\npcap-sdk" >> $env:GITHUB_ENV |
| 26 | + shell: pwsh |
16 | 27 |
|
17 | | - - name: Setup MSBuild |
18 | | - uses: microsoft/setup-msbuild@v1 |
| 28 | + # 3. Configure MSVC x64 environment |
| 29 | + - name: Setup MSVC Developer Command Prompt |
| 30 | + uses: ilammy/msvc-dev-cmd@v1 |
| 31 | + with: |
| 32 | + arch: x64 |
19 | 33 |
|
| 34 | + # 4. Build masscan.exe using the provided Makefile.msvc |
20 | 35 | - name: Build masscan |
21 | 36 | run: | |
22 | | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64 -host_arch=x64 |
23 | | - nmake -f Makefile.msvc all |
| 37 | + nmake -f Makefile.msvc |
| 38 | + shell: cmd |
24 | 39 |
|
| 40 | + # 5. Verify the executable was created |
| 41 | + - name: Check binary |
| 42 | + run: | |
| 43 | + if not exist "bin\masscan.exe" exit /b 1 |
| 44 | + shell: cmd |
| 45 | + |
| 46 | + # 6. Upload the exe as an artifact (useful for testing on every push) |
25 | 47 | - name: Upload artifact |
26 | 48 | uses: actions/upload-artifact@v4 |
27 | 49 | with: |
28 | 50 | name: masscan-win64 |
29 | 51 | path: bin\masscan.exe |
| 52 | + |
| 53 | + # 7. Create a GitHub Release and attach the exe (only on tag pushes) |
| 54 | + - name: Create Release |
| 55 | + if: startsWith(github.ref, 'refs/tags/') |
| 56 | + uses: softprops/action-gh-release@v2 |
| 57 | + with: |
| 58 | + files: bin\masscan.exe |
| 59 | + name: ${{ github.ref_name }} |
| 60 | + body: | |
| 61 | + Automated masscan Windows 64-bit build. |
| 62 | + Commit: ${{ github.sha }} |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments