bettercap/.github/workflows/build-and-deploy.yml
2024-09-27 20:23:57 +02:00

105 lines
3.2 KiB
YAML

name: Build and Deploy
on:
push:
tags:
- 'v*.*.*' # Match version tags
workflow_dispatch:
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: macos-latest
arch: arm64
target_os: darwin
target_arch: arm64
- 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 libusb via mingw (Windows)
if: ${{ matrix.os == 'windows-latest' }}
uses: msys2/setup-msys2@v2
with:
install: |-
mingw64/mingw-w64-x86_64-libusb
mingw64/mingw-w64-x86_64-pkg-config
- name: Install other Dependencies (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
choco install openssl.light -y
choco install make -y
choco install 7zip -y
choco install zadig -y
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"
echo "D:\a\_temp\msys64\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Build
run: make -e TARGET="${{ env.OUTPUT }}"
- 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"
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
with:
submodules: true
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
with:
files: |
bettercap_*.zip
bettercap_*.sha256
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}