Skip to content

CI: build binaries for linux and macOS #44

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

Merged
merged 9 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/excludes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@
^\Q.github/workflows/spelling.yml\E$
^\Qbin/.placeholder\E$
ignore$
^\.github/workflows/
63 changes: 63 additions & 0 deletions .github/workflows/go-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:

build_linux:
# TODO: see if we can cross compile for other archs with CGo
runs-on: ubuntu-22.04
name: Go build (Linux)
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
check-latest: true

- name: Build (amd64)
run: GOOS=linux GOARCH=amd64 CGO_ENABLED=1 ./build.sh
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: lightningstream_linux_amd64.bin
path: bin/lightningstream

build_macos:
# We use one version older than the latest, to ensure compatibility
runs-on: macos-11
name: Go build (macOS)
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.20'
check-latest: true

- name: Build (amd64)
run: GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 ./build.sh
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: lightningstream_darwin_amd64.bin
path: bin/lightningstream

- name: Build (arm64)
run: GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 ./build.sh
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: lightningstream_darwin_arm64.bin
path: bin/lightningstream

12 changes: 8 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ name: Go Tests

on:
push:
branches: [ "main" ]
branches:
- main
pull_request:
branches: [ "main" ]
branches:
- main

jobs:

build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
matrix:
go: [ '1.20', '1.19' ]
go:
- '1.19'
- '1.20'

name: Go ${{ matrix.go }} tests
steps:
Expand Down
7 changes: 5 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ fi

for cmd in cmd/*; do
if [ -d "$cmd" ]; then
echo "+ go install \"./$cmd\""
go install "./$cmd"
name=$(basename "$cmd")
# go install refuses to install cross-compiled binaries
# https://github.com/golang/go/issues/57485
echo "go build -o $GOBIN/$name ./$cmd"
go build -o "$GOBIN/$name" "./$cmd"
fi
done

Expand Down