1
1
mirror of https://gitea.com/gitea/tea synced 2024-11-23 00:12:05 +01:00

Use gox to cross-compile (#274)

use gox for cross-compile

use xgo base image

correct flags for gox

no need to test drone anymore

Co-authored-by: Matti R <matti@mdranta.net>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/274
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Co-Authored-By: techknowlogick <techknowlogick@gitea.io>
Co-Committed-By: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
techknowlogick 2020-12-09 01:45:48 +08:00 committed by 6543
parent c98441b13c
commit 3acd42f8d7
2 changed files with 7 additions and 41 deletions

@ -6,10 +6,6 @@ platform:
os: linux os: linux
arch: amd64 arch: amd64
workspace:
base: /go
path: src/code.gitea.io/tea
steps: steps:
- name: build - name: build
pull: always pull: always
@ -31,7 +27,6 @@ steps:
- pull_request - pull_request
- name: unit-test - name: unit-test
pull: always
image: golang:1.15 image: golang:1.15
commands: commands:
- make unit-test-coverage - make unit-test-coverage
@ -45,7 +40,6 @@ steps:
- pull_request - pull_request
- name: release-test - name: release-test
pull: always
image: golang:1.15 image: golang:1.15
commands: commands:
- make test - make test
@ -70,8 +64,7 @@ steps:
- tag - tag
- name: static - name: static
pull: always image: golang:1.15
image: techknowlogick/xgo:latest
environment: environment:
GOPROXY: https://goproxy.cn GOPROXY: https://goproxy.cn
commands: commands:

@ -140,45 +140,18 @@ $(EXECUTABLE): $(SOURCES)
$(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@ $(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
.PHONY: release .PHONY: release
release: release-dirs release-windows release-linux release-darwin release-copy release-compress release-check release: release-dirs release-os release-compress release-check
.PHONY: release-dirs .PHONY: release-dirs
release-dirs: release-dirs:
mkdir -p $(DIST)/binaries $(DIST)/release mkdir -p $(DIST)/binaries $(DIST)/release
.PHONY: release-windows .PHONY: release-os
release-windows: release-os:
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ @hash gox > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
cd /tmp && $(GO) get -u src.techknowlogick.com/xgo; \ cd /tmp && $(GO) get -u github.com/mitchellh/gox; \
fi fi
GO111MODULE=off xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out tea-$(VERSION) . CGO_ENABLED=0 gox -verbose -cgo=false -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -osarch='!darwin/386 !darwin/arm64 !darwin/arm' -os="windows linux darwin" -arch="386 amd64 arm arm64" -output="$(DIST)/binaries/release/tea-$(VERSION)-{{.OS}}-{{.Arch}}"
ifeq ($(CI),drone)
cp /build/* $(DIST)/binaries
endif
.PHONY: release-linux
release-linux:
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
cd /tmp && $(GO) get -u src.techknowlogick.com/xgo; \
fi
GO111MODULE=off xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/mips64le,linux/mips,linux/mipsle' -out tea-$(VERSION) .
ifeq ($(CI),drone)
cp /build/* $(DIST)/binaries
endif
.PHONY: release-darwin
release-darwin:
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
cd /tmp && $(GO) get -u src.techknowlogick.com/xgo; \
fi
GO111MODULE=off xgo -dest $(DIST)/binaries -tags 'netgo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin/*' -out tea-$(VERSION) .
ifeq ($(CI),drone)
cp /build/* $(DIST)/binaries
endif
.PHONY: release-copy
release-copy:
cd $(DIST); for file in `find /build -type f -name "*"`; do cp $${file} ./release/; done;
.PHONY: release-compress .PHONY: release-compress
release-compress: release-compress: