Skip to content

Commit e13b252

Browse files
committed
test xcgo build
1 parent baceba0 commit e13b252

File tree

4 files changed

+82
-92
lines changed

4 files changed

+82
-92
lines changed

.github/workflows/build.yml

+18-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ jobs:
1515
- name: checkout
1616
uses: actions/checkout@v2
1717

18+
# unshallow (for goreleaser)
19+
- name: unshallow
20+
run: git fetch --prune --unshallow
21+
22+
# setup go
23+
- name: go
24+
uses: actions/setup-go@v1
25+
with:
26+
go-version: 1.14.1
27+
1828
# lint
1929
- name: lint
2030
run: |
@@ -42,4 +52,11 @@ jobs:
4252
# build
4353
- name: build
4454
run: |
45-
make build
55+
make snapshot
56+
57+
# artifact
58+
- name: artifact
59+
uses: actions/upload-artifact@v1
60+
with:
61+
name: build_${GITHUB_SHA}
62+
path: dist/

.goreleaser.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# https://goreleaser.com
2+
project_name: mediarr
3+
4+
# Build
5+
builds:
6+
-
7+
env:
8+
- CGO_ENABLED=1
9+
goos:
10+
- linux
11+
- darwin
12+
- windows
13+
goarch:
14+
- amd64
15+
ldflags:
16+
- -s -w
17+
- -X "github.com/l3uddz/mediarr/build.Version={{ .Version }}"
18+
- -X "github.com/l3uddz/mediarr/build.GitCommit={{ .ShortCommit }}"
19+
- -X "github.com/l3uddz/mediarr/build.Timestamp={{ .Timestamp }}"
20+
flags:
21+
- -trimpath
22+
23+
# Archive
24+
archives:
25+
-
26+
name_template: "{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}"
27+
format: "tar.gz"
28+
29+
# Checksum
30+
checksum:
31+
name_template: "checksums.txt"
32+
algorithm: sha512
33+
34+
# Snapshot
35+
snapshot:
36+
name_template: "{{ .Major }}.{{ .Minor }}.{{ .Patch }}-dev+{{ .ShortCommit }}"
37+
38+
# Changelog
39+
changelog:
40+
sort: asc
41+
filters:
42+
exclude:
43+
- "^docs:"
44+
- "^test:"

Makefile

+20-10
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ GIT_COMMIT := $(shell git rev-parse --short HEAD)
1212
# GIT_BRANCH := $(shell git symbolic-ref --short HEAD)
1313
TIMESTAMP := $(shell date +%s)
1414
VERSION ?= 0.0.0-dev
15+
CGO := 1
1516

1617
# Deps
1718
.PHONY: check_golangci
1819
check_golangci:
1920
@command -v golangci-lint >/dev/null || (echo "golangci-lint is required."; exit 1)
20-
.PHONY: check_goreleaser
21-
check_goreleaser:
22-
@command -v goreleaser >/dev/null || (echo "goreleaser is required."; exit 1)
2321

2422
.PHONY: all ## Run tests, linting and build
2523
all: test lint build
@@ -54,7 +52,7 @@ build: fetch ${BUILD_PATH}/${CMD} ## Build application
5452
${BUILD_PATH}/${CMD}: ${GO_FILES} go.sum
5553
@echo "Building for ${TARGET}..." && \
5654
mkdir -p ${BUILD_PATH} && \
57-
CGO_ENABLED=1 go build \
55+
CGO_ENABLED=${CGO} go build \
5856
-mod vendor \
5957
-trimpath \
6058
-ldflags "-s -w -X github.com/l3uddz/mediarr/build.Version=${VERSION} -X github.com/l3uddz/mediarr/build.GitCommit=${GIT_COMMIT} -X github.com/l3uddz/mediarr/build.Timestamp=${TIMESTAMP}" \
@@ -74,16 +72,28 @@ fetch: ## Fetch vendor files
7472
go mod vendor
7573

7674
.PHONY: release
77-
release: check_goreleaser fetch ## Generate a release, but don't publish
78-
goreleaser --skip-validate --skip-publish --rm-dist
75+
release: fetch ## Generate a release, but don't publish
76+
docker run --rm --privileged \
77+
-v $(pwd):/go/src/github.com/l3uddz/mediarr \
78+
-v /var/run/docker.sock:/var/run/docker.sock \
79+
-w /go/src/github.com/l3uddz/mediarr \
80+
neilotoole/xcgo:latest goreleaser --skip-validate --skip-publish --rm-dist
7981

8082
.PHONY: publish
81-
publish: check_goreleaser fetch ## Generate a release, and publish
82-
goreleaser --rm-dist
83+
publish: fetch ## Generate a release, and publish
84+
docker run --rm --privileged \
85+
-v $(pwd):/go/src/github.com/l3uddz/mediarr \
86+
-v /var/run/docker.sock:/var/run/docker.sock \
87+
-w /go/src/github.com/l3uddz/mediarr \
88+
neilotoole/xcgo:latest goreleaser --rm-dist
8389

8490
.PHONY: snapshot
85-
snapshot: check_goreleaser fetch ## Generate a snapshot release
86-
goreleaser --snapshot --skip-validate --skip-publish --rm-dist
91+
snapshot: fetch ## Generate a snapshot release
92+
docker run --rm --privileged \
93+
-v $(pwd):/go/src/github.com/l3uddz/mediarr \
94+
-v /var/run/docker.sock:/var/run/docker.sock \
95+
-w /go/src/github.com/l3uddz/mediarr \
96+
neilotoole/xcgo:latest goreleaser --snapshot --skip-validate --skip-publish --rm-dist
8797

8898
.PHONY: help
8999
help:

appveyor_oldd.yml

-81
This file was deleted.

0 commit comments

Comments
 (0)