Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically build binaries for Popular Linux archs #253

Merged
merged 14 commits into from
Dec 8, 2022
42 changes: 42 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build Linux Binaries

on:
release:
types: [published]
env:
MOSQUITTO_VERSION: 2.0.15
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: download mosquitto
run: |
curl -o mosquitto.tgz https://mosquitto.org/files/source/mosquitto-${{ env.MOSQUITTO_VERSION }}.tar.gz
tar -zxf mosquitto.tgz
mkdir -p output/linux-amd64 output/linux-arm64 output/linux-armv7 output/linux-armv6
- name: Checkout
uses: actions/checkout@v3
with:
path: mosquitto-go-auth
- name: run build
uses: addnab/docker-run-action@v3
with:
image: golang:latest
options: -e MOSQUITTO_VERSION=${{ env.MOSQUITTO_VERSION }} -v ${{ github.workspace }}:/usr/src -w /usr/src
run: |
/usr/src/mosquitto-go-auth/.github/workflows/scripts/build.sh
- name: zip
run: |
cd ${{ github.workspace }}/output
zip -r linux-amd64.zip linux-amd64
zip -r linux-arm64.zip linux-arm64
zip -r linux-armv7.zip linux-armv7
zip -r linux-armv6.zip linux-armv6
- name: Release files
uses: softprops/action-gh-release@v1
with:
files: |
output/linux-amd64.zip
output/linux-arm64.zip
output/linux-armv6.zip
output/linux-armv7.zip
37 changes: 37 additions & 0 deletions .github/workflows/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

apt-get update
apt-get install -y gcc-arm-linux-gnueabi binutils-arm-linux-gnueabi gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
cd /usr/src/mosquitto-$MOSQUITTO_VERSION/include
cp *.h /usr/include
cd /usr/src/mosquitto-go-auth

#build amd64 Linux
make
cp go-auth.so pw /usr/src/output/linux-amd64

# build arm64 Linux
make clean
export CGO_ENABLED=1
export GOARCH=arm64
export CC=aarch64-linux-gnu-gcc
make
cp go-auth.so pw /usr/src/output/linux-arm64

# build armv7 Linux
make clean
export CGO_ENABLED=1
export GOARCH=arm
export GOARM=7
export CC=arm-linux-gnueabi-gcc
make
cp go-auth.so pw /usr/src/output/linux-armv7

# build armv7 Linux
make clean
export CGO_ENABLED=1
export GOARCH=arm
export GOARM=6
export CC=arm-linux-gnueabi-gcc
make
cp go-auth.so pw /usr/src/output/linux-armv6