mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 21:43:18 -07:00
new: added github workflows (ref #1114)
This commit is contained in:
parent
8b24723c18
commit
632d703087
2 changed files with 152 additions and 0 deletions
116
.github/workflows/main.yml
vendored
Normal file
116
.github/workflows/main.yml
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
name: Build, Test and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*' # Match version tags
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
go-version: ['1.22.x']
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
arch: amd64
|
||||
target_os: linux
|
||||
target_arch: amd64
|
||||
- os: ubuntu-latest
|
||||
arch: arm64
|
||||
target_os: linux
|
||||
target_arch: aarch64
|
||||
- os: ubuntu-latest
|
||||
arch: amd64
|
||||
target_os: linux
|
||||
target_arch: armhf
|
||||
cross_build: true
|
||||
- os: macos-latest
|
||||
arch: amd64
|
||||
target_os: darwin
|
||||
target_arch: amd64
|
||||
- os: windows-latest
|
||||
arch: amd64
|
||||
target_os: windows
|
||||
target_arch: amd64
|
||||
output: bettercap.exe
|
||||
|
||||
env:
|
||||
TARGET_OS: ${{ matrix.target_os }}
|
||||
TARGET_ARCH: ${{ matrix.target_arch }}
|
||||
GO_VERSION: ${{ matrix.go-version }}
|
||||
OUTPUT: ${{ matrix.output || 'bettercap' }}
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Install Dependencies
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
run: sudo apt-get update && sudo apt-get install -y p7zip-full libpcap-dev libnetfilter-queue-dev libusb-1.0-0-dev
|
||||
|
||||
- name: Install Dependencies (macOS)
|
||||
if: ${{ matrix.os == 'macos-latest' }}
|
||||
run: brew install libpcap libusb p7zip
|
||||
|
||||
- name: Install Dependencies (Windows)
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
run: |
|
||||
choco install openssl.light -y
|
||||
choco install make -y
|
||||
choco install 7zip -y
|
||||
choco install pkgconfiglite -y
|
||||
mkdir C:\pkg-config
|
||||
choco install zadig -y
|
||||
curl -L "https://github.com/libusb/libusb/releases/download/v1.0.24/libusb-1.0.24.7z" -o "C:\libusb.7z"
|
||||
7z x -y "C:\libusb.7z" -o"C:\libusb"
|
||||
curl -L "https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip" -o "C:\wpcap-sdk.zip"
|
||||
7z x -y "C:\wpcap-sdk.zip" -o"C:\winpcap"
|
||||
copy builder\libusb.pc C:\pkg-config\libusb.pc
|
||||
copy builder\libusb.pc C:\pkg-config\libusb-1.0.pc
|
||||
|
||||
- name: Install QEMU for Cross Compilation (Linux only)
|
||||
if: matrix.cross_build && matrix.os == 'ubuntu-latest'
|
||||
run: |
|
||||
wget --show-progress -qcO "qemu.deb" "https://github.com/bettercap/buildutils/raw/main/qemu-user-static_5.2_dfsg-9_amd64.deb"
|
||||
sudo dpkg -i "qemu.deb"
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
if [ -n "${{matrix.cross_build}}" ]; then
|
||||
sudo builder/arm_builder.sh bettercap make -e TARGET="${{ env.OUTPUT }}"
|
||||
else
|
||||
make -e TARGET="${{ env.OUTPUT }}"
|
||||
fi
|
||||
|
||||
- name: Verify Build
|
||||
run: |
|
||||
file "${{ env.OUTPUT }}"
|
||||
openssl dgst -sha256 "${{ env.OUTPUT }}" | tee bettercap_${{ matrix.target_os }}_${{ matrix.target_arch }}_${{ env.VERSION }}.sha256
|
||||
7z a "bettercap_${{ matrix.target_os }}_${{ matrix.target_arch }}_${{ env.VERSION }}.zip" "${{ env.OUTPUT }}" "bettercap_${{ matrix.target_os }}_${{ matrix.target_arch }}_${{ env.VERSION }}.sha256"
|
||||
ls -la bettercap*
|
||||
|
||||
# Deployment is triggered on push of version tags and the files are already zipped and hashed during the build job.
|
||||
deploy:
|
||||
needs: [build]
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Upload Release Assets
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: |
|
||||
bettercap_*.zip
|
||||
bettercap_*.sha256
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
36
.github/workflows/test.yml
vendored
Normal file
36
.github/workflows/test.yml
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
name: Build and Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
go-version: ['1.22.x']
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Install Dependencies
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
run: sudo apt-get update && sudo apt-get install -y p7zip-full libpcap-dev libnetfilter-queue-dev libusb-1.0-0-dev
|
||||
|
||||
- name: Install Dependencies (macOS)
|
||||
if: ${{ matrix.os == 'macos-latest' }}
|
||||
run: brew install libpcap libusb p7zip
|
||||
|
||||
- name: Run Tests
|
||||
run: |
|
||||
env GO111MODULE=on make test
|
Loading…
Add table
Add a link
Reference in a new issue