fix(ci): Store release assets to the GitHub release

Those changes fix several issues.

First, artifacts were not stored between jobs, so when publishing release assets, nothing was found.
It explains why the latest GitHub release assets list contains only ZIP'ed sources.

Secondly, the workflow matrix was not working as expected: for instance, Linux AMD64 was run alone
while both AMD64 and ARM64 were expected.

Thirdly, even if the Linux matrix is fixed, there is no official GitHub runner for ARM64 yet.
so this is disabled by default for now (I wanted to propose changes about the workflow, not to
fix all issues at once).
This commit is contained in:
Mickaël Schoentgen 2024-09-27 19:40:46 +02:00
commit 3b4cdc60cb

View file

@ -8,35 +8,37 @@ on:
jobs: jobs:
build: build:
runs-on: ${{ matrix.os }} name: ${{ matrix.os.pretty }} ${{ matrix.arch }}
runs-on: ${{ matrix.os.runs-on }}
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] os:
go-version: ['1.22.x'] - name: darwin
include: runs-on: [macos-latest]
- os: ubuntu-latest pretty: 🍎 macOS
arch: amd64 - name: linux
target_os: linux runs-on: [ubuntu-latest]
target_arch: amd64 pretty: 🐧 Linux
- os: ubuntu-latest - name: windows
arch: arm64 runs-on: [windows-latest]
target_os: linux pretty: 🪟 Windows
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 output: bettercap.exe
arch: [amd64, arm64]
go: [1.22.x]
exclude:
- os:
name: darwin
arch: amd64
# Linux ARM64 images are not yet publicly available (https://github.com/actions/runner-images)
- os:
name: linux
arch: arm64
- os:
name: windows
arch: arm64
env: env:
TARGET_OS: ${{ matrix.target_os }} OUTPUT: ${{ matrix.os.output || 'bettercap' }}
TARGET_ARCH: ${{ matrix.target_arch }}
GO_VERSION: ${{ matrix.go-version }}
OUTPUT: ${{ matrix.output || 'bettercap' }}
steps: steps:
- name: Checkout Code - name: Checkout Code
@ -47,19 +49,18 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go }}
- name: Install Dependencies - name: Install Dependencies
if: ${{ matrix.os == 'ubuntu-latest' }} if: ${{ matrix.os.name == 'linux' }}
run: sudo apt-get update && sudo apt-get install -y p7zip-full libpcap-dev libnetfilter-queue-dev libusb-1.0-0-dev 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) - name: Install Dependencies (macOS)
if: ${{ matrix.os == 'macos-latest' }} if: ${{ matrix.os.name == 'macos' }}
run: brew install libpcap libusb p7zip run: brew install libpcap libusb p7zip
- name: Install libusb via mingw (Windows) - name: Install libusb via mingw (Windows)
if: ${{ matrix.os == 'windows-latest' }} if: ${{ matrix.os.name == 'windows' }}
uses: msys2/setup-msys2@v2 uses: msys2/setup-msys2@v2
with: with:
install: |- install: |-
@ -67,7 +68,7 @@ jobs:
mingw64/mingw-w64-x86_64-pkg-config mingw64/mingw-w64-x86_64-pkg-config
- name: Install other Dependencies (Windows) - name: Install other Dependencies (Windows)
if: ${{ matrix.os == 'windows-latest' }} if: ${{ matrix.os.name == 'windows' }}
run: | run: |
choco install openssl.light -y choco install openssl.light -y
choco install make -y choco install make -y
@ -83,25 +84,36 @@ jobs:
- name: Verify Build - name: Verify Build
run: | run: |
file "${{ env.OUTPUT }}" file "${{ env.OUTPUT }}"
openssl dgst -sha256 "${{ env.OUTPUT }}" | tee bettercap_${{ matrix.target_os }}_${{ matrix.target_arch }}_${{ env.VERSION }}.sha256 openssl dgst -sha256 "${{ env.OUTPUT }}" | tee bettercap_${{ matrix.os.name }}_${{ matrix.arch }}.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" 7z a "bettercap_${{ matrix.os.name }}_${{ matrix.arch }}.zip" "${{ env.OUTPUT }}" "bettercap_${{ matrix.os.name }}_${{ matrix.arch }}.sha256"
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts-${{ matrix.os.name }}-${{ matrix.arch }}
path: |
bettercap_*.zip
bettercap_*.sha256
deploy: deploy:
needs: [build] needs: [build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
name: Release name: Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Code - name: Download Artifacts
uses: actions/checkout@v2 uses: actions/download-artifact@v4
with: with:
submodules: true pattern: release-artifacts-*
merge-multiple: true
path: dist/
- name: Release Assets
run: ls -l dist
- name: Upload Release Assets - name: Upload Release Assets
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v2
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
with: with:
files: | files: dist/bettercap_*
bettercap_*.zip
bettercap_*.sha256
env: env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}