Skip to content

Commit

Permalink
Run CLI release build on target OS (#377)
Browse files Browse the repository at this point in the history
This unfortunately drops support for windows ARM in favor of fixing the
other builds. Support should be introduced again as soon as we have time
to sort the necessary build flags out.
  • Loading branch information
wkalt authored Apr 28, 2022
1 parent d13e0c5 commit 152b9d1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 25 deletions.
62 changes: 40 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,48 +262,66 @@ jobs:
go-release-cli:
permissions:
contents: write
runs-on: ubuntu-latest
needs:
- go
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/releases/mcap-cli/v')
defaults:
run:
working-directory: go/cli/mcap
strategy:
fail-fast: false
matrix:
goosarch:
- "darwin/amd64"
- "darwin/arm64"
- "linux/amd64"
- "linux/arm64"
- "windows/amd64"
- "windows/arm"
include:
- os: linux
image: ubuntu-latest
arch: amd64
env: {}
- os: linux
image: ubuntu-latest
arch: arm64
setup: sudo apt-get update && sudo apt-get install -qq gcc-aarch64-linux-gnu
env:
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
- os: macos
image: macos-latest
arch: amd64
env: {}
- os: macos
image: macos-latest
arch: arm64
env: {}
- os: windows
image: windows-latest
arch: amd64
env: {}

name: Build (${{ matrix.os }}/${{ matrix.arch }})
runs-on: ${{ matrix.image }}
env: ${{ matrix.env }}

steps:
- uses: actions/checkout@v2
with:
fetch-depth: "0"
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- uses: actions/setup-go@v3
with:
go-version: 1.18.x
- name: Get OS and arch info
run: |
GOOSARCH=${{matrix.goosarch}}
GOOS=${GOOSARCH%/*}
GOARCH=${GOOSARCH#*/}
BINARY_NAME=mcap-$GOOS-$GOARCH
if [[ "$BINARY_NAME" =~ .*windows.* ]]; then
BINARY_NAME=$BINARY_NAME.exe
fi
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
echo "GOOS=$GOOS" >> $GITHUB_ENV
echo "GOARCH=$GOARCH" >> $GITHUB_ENV
- name: Setup environment
run: ${{ matrix.setup }}
- name: Build binary
run: make build -e BINARY_NAME=$BINARY_NAME
run: make build
env:
GOARCH: ${{ matrix.arch }}
OUTPUT: mcap-${{ matrix.os }}-${{ matrix.arch }}
- name: Make release notes
run: |
git log --oneline --no-merges --first-parent --grep CLI --decorate-refs=refs $(git describe --tags $(git rev-list --tags=releases/mcap-cli --max-count=1))..HEAD > ${{ github.workspace }}-CHANGELOG.txt
- name: Release
uses: softprops/action-gh-release@v1
with:
files: ./go/cli/mcap/bin/${{env.BINARY_NAME}}
files: ./go/cli/mcap/bin/*
body_path: ${{ github.workspace }}-CHANGELOG.txt
draft: false

Expand Down
13 changes: 10 additions & 3 deletions go/cli/mcap/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
SHELL=/bin/bash
BINARY_NAME ?= mcap
# enable cgo to build sqlite
export CGO_ENABLED = 1

GOOS=$(shell go env GOOS)

OUTPUT ?= mcap

ifeq ($(GOOS),windows)
OUTPUT := $(addsuffix .exe,$(OUTPUT))
endif

ifeq ($(GOOS),linux)
flags:: version
# statically link binaries to support alpine linux
Expand All @@ -17,7 +24,7 @@ version:

build: flags
mkdir -p bin
go build -o bin/$(BINARY_NAME) $(subst $\",,$(FLAGS)) .
go build -o bin/$(OUTPUT) $(subst $\",,$(FLAGS)) .

lint:
golangci-lint run ./...
Expand Down

0 comments on commit 152b9d1

Please sign in to comment.