Create binaries for armv7 and arm64 (#111)

This commit is contained in:
Antonio Navarro Perez 2021-12-19 03:00:51 -08:00 committed by GitHub
parent 36cc016f9d
commit a1b8cd1c7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 28 deletions

View file

@ -1,5 +1,5 @@
--- ---
name: build-32 name: build-arm
# Trigger the workflow on push or pull request # Trigger the workflow on push or pull request
on: on:
@ -13,7 +13,16 @@ on:
jobs: jobs:
build_job: build_job:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
name: ubuntu-20.04 armv7 name: linux_${{ matrix.arch }}
strategy:
matrix:
include:
- arch: armv7
go: 1.17.5
go_arch: armv6l
- arch: aarch64
go: 1.17.5
go_arch: arm64
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
name: Checkout name: Checkout
@ -23,7 +32,7 @@ jobs:
name: Test and Build name: Test and Build
id: runcmd id: runcmd
with: with:
arch: armv7 arch: ${{ matrix.arch }}
distro: ubuntu20.04 distro: ubuntu20.04
githubToken: ${{ github.token }} githubToken: ${{ github.token }}
@ -39,18 +48,25 @@ jobs:
export PATH=$PATH:/usr/local/go/bin export PATH=$PATH:/usr/local/go/bin
rm -rf /usr/local/go rm -rf /usr/local/go
mkdir -p /usr/local/go mkdir -p /usr/local/go
curl -s -L https://golang.org/dl/go1.17.linux-armv6l.tar.gz | tar -C /usr/local -xz curl -s -L https://golang.org/dl/go${{ matrix.go }}.linux-${{ matrix.go_arch }}.tar.gz | tar -C /usr/local -xz
go version go version
make test make test
make build make build
cp bin/* /artifacts cp bin/* /artifacts
- name: Show the artifact - name: Show artifacts
run: | run: |
ls -al "/tmp/artifacts" ls -al "/tmp/artifacts"
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
if-no-files-found: error if-no-files-found: error
name: build-armv7 name: build-${{ matrix.arch }}
path: "/tmp/artifacts/*" path: "/tmp/artifacts/*"
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: "/tmp/artifacts/*"

View file

@ -114,11 +114,6 @@ jobs:
shell: bash shell: bash
run: | run: |
make build make build
- name: Cross-compile
shell: bash
run: |
make cross-compile
if: matrix.os == 'ubuntu-latest'
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2

View file

@ -5,10 +5,6 @@ BUILD := $(shell git rev-parse --short HEAD)
BIN_OUTPUT ?= bin/distribyted-$(VERSION)-`go env GOOS`-`go env GOARCH``go env GOEXE` BIN_OUTPUT ?= bin/distribyted-$(VERSION)-`go env GOOS`-`go env GOARCH``go env GOEXE`
PROJECTNAME := $(shell basename "$(PWD)") PROJECTNAME := $(shell basename "$(PWD)")
go-cross-compile: GOPATH=~/go
go-cross-compile: ORGPATH=$(GOPATH)/src/github.com/distribyted
go-cross-compile: REPOPATH=$(ORGPATH)/distribyted
# Use linker flags to provide version/build settings # Use linker flags to provide version/build settings
LDFLAGS=-X=main.Version=$(VERSION) -X=main.Build=$(BUILD) -linkmode external LDFLAGS=-X=main.Version=$(VERSION) -X=main.Build=$(BUILD) -linkmode external
@ -30,9 +26,6 @@ test-race:
test: test:
CGO_ENABLED=1 go test -v -coverprofile=coverage.out ./... CGO_ENABLED=1 go test -v -coverprofile=coverage.out ./...
## cross-compile: compile for other platforms using xgo.
cross-compile: go-generate go-cross-compile
go-build: go-build:
@echo " > Building binary on $(BIN_OUTPUT)..." @echo " > Building binary on $(BIN_OUTPUT)..."
go build -o $(BIN_OUTPUT) -tags "release" -ldflags='$(LDFLAGS)' cmd/distribyted/main.go go build -o $(BIN_OUTPUT) -tags "release" -ldflags='$(LDFLAGS)' cmd/distribyted/main.go
@ -41,15 +34,6 @@ go-generate:
@echo " > Generating code files..." @echo " > Generating code files..."
go generate ./... go generate ./...
go-cross-compile:
@echo " > Compiling for several platforms..."
go install src.techknowlogick.com/xgo@latest
docker build ./build_tools/ -t distribyted/xgo-cgofuse
mkdir -p $(ORGPATH)
ln -sfrnT . $(REPOPATH)
GOPATH=$(GOPATH) xgo -out bin/distribyted-$(VERSION) -image=distribyted/xgo-cgofuse -ldflags='$(LDFLAGS)' -tags="release" -targets=linux/arm-7 $(REPOPATH)
.PHONY: help .PHONY: help
all: help all: help
help: Makefile help: Makefile