Debian Codegraph @

.github/workflows/deploy.yml

raw symbols SCIP
1 name: Build and Deploy
2
3 on:
4 push:
5 tags:
6 - 'v*.*.*' # Match version tags
7
8 jobs:
9 build:
10 runs-on: ${{ matrix.os }}
11 strategy:
12 matrix:
13 os: [ubuntu-latest, macos-latest, windows-latest]
14 go-version: ['1.22.x']
15 include:
16 - os: ubuntu-latest
17 arch: amd64
18 target_os: linux
19 target_arch: amd64
20 - os: ubuntu-latest
21 arch: arm64
22 target_os: linux
23 target_arch: aarch64
24 - os: ubuntu-latest
25 arch: amd64
26 target_os: linux
27 target_arch: armhf
28 cross_build: true
29 - os: macos-latest
30 arch: amd64
31 target_os: darwin
32 target_arch: amd64
33 - os: windows-latest
34 arch: amd64
35 target_os: windows
36 target_arch: amd64
37 output: bettercap.exe
38
39 env:
40 TARGET_OS: ${{ matrix.target_os }}
41 TARGET_ARCH: ${{ matrix.target_arch }}
42 GO_VERSION: ${{ matrix.go-version }}
43 OUTPUT: ${{ matrix.output || 'bettercap' }}
44
45 steps:
46 - name: Checkout Code
47 uses: actions/checkout@v2
48
49 - name: Set up Go
50 uses: actions/setup-go@v2
51 with:
52 go-version: ${{ matrix.go-version }}
53
54 - name: Install Dependencies
55 if: ${{ matrix.os == 'ubuntu-latest' }}
56 run: sudo apt-get update && sudo apt-get install -y p7zip-full libpcap-dev libnetfilter-queue-dev libusb-1.0-0-dev
57
58 - name: Install Dependencies (macOS)
59 if: ${{ matrix.os == 'macos-latest' }}
60 run: brew install libpcap libusb p7zip
61
62 - name: Install Dependencies (Windows)
63 if: ${{ matrix.os == 'windows-latest' }}
64 run: |
65 choco install openssl.light -y
66 choco install make -y
67 choco install 7zip -y
68 choco install pkgconfiglite -y
69 mkdir C:\pkg-config
70 choco install zadig -y
71 curl -L "https://github.com/libusb/libusb/releases/download/v1.0.24/libusb-1.0.24.7z" -o "C:\libusb.7z"
72 7z x -y "C:\libusb.7z" -o"C:\libusb"
73 curl -L "https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip" -o "C:\wpcap-sdk.zip"
74 7z x -y "C:\wpcap-sdk.zip" -o"C:\winpcap"
75 copy builder\libusb.pc C:\pkg-config\libusb.pc
76 copy builder\libusb.pc C:\pkg-config\libusb-1.0.pc
77
78 - name: Install QEMU for Cross Compilation (Linux only)
79 if: matrix.cross_build && matrix.os == 'ubuntu-latest'
80 run: |
81 wget --show-progress -qcO "qemu.deb" "https://github.com/bettercap/buildutils/raw/main/qemu-user-static_5.2_dfsg-9_amd64.deb"
82 sudo dpkg -i "qemu.deb"
83
84 - name: Build
85 run: |
86 if [ -n "${{matrix.cross_build}}" ]; then
87 sudo builder/arm_builder.sh bettercap make -e TARGET="${{ env.OUTPUT }}"
88 else
89 make -e TARGET="${{ env.OUTPUT }}"
90 fi
91
92 - name: Verify Build
93 run: |
94 file "${{ env.OUTPUT }}"
95 openssl dgst -sha256 "${{ env.OUTPUT }}" | tee bettercap_${{ matrix.target_os }}_${{ matrix.target_arch }}_${{ env.VERSION }}.sha256
96 7z a "bettercap_${{ matrix.target_os }}_${{ matrix.target_arch }}_${{ env.VERSION }}.zip" "${{ env.OUTPUT }}" "bettercap_${{ matrix.target_os }}_${{ matrix.target_arch }}_${{ env.VERSION }}.sha256"
97 ls -la bettercap*
98
99 # Deployment is triggered on push of version tags and the files are already zipped and hashed during the build job.
100 deploy:
101 needs: [build]
102 if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
103 name: Release
104 runs-on: ubuntu-latest
105 steps:
106 - name: Checkout Code
107 uses: actions/checkout@v2
108
109 - name: Upload Release Assets
110 uses: softprops/action-gh-release@v1
111 with:
112 files: |
113 bettercap_*.zip
114 bettercap_*.sha256
115 env:
116 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}