Skip to content

Commit 31017f6

Browse files
committed
GitHub Actions cross
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
1 parent 56e5910 commit 31017f6

File tree

7 files changed

+87
-84
lines changed

7 files changed

+87
-84
lines changed

.circleci/config.yml

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,6 @@ version: 2
22

33
jobs:
44

5-
cross:
6-
working_directory: /work
7-
docker: [{image: 'docker:20.10-git'}]
8-
environment:
9-
DOCKER_BUILDKIT: 1
10-
BUILDX_VERSION: "v0.6.0"
11-
parallelism: 3
12-
steps:
13-
- checkout
14-
- setup_remote_docker:
15-
version: 20.10.6
16-
reusable: true
17-
exclusive: false
18-
- run:
19-
name: "Docker version"
20-
command: docker version
21-
- run:
22-
name: "Docker info"
23-
command: docker info
24-
- run: apk add make curl
25-
- run: mkdir -vp ~/.docker/cli-plugins/
26-
- run: curl -fsSL --output ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64
27-
- run: chmod a+x ~/.docker/cli-plugins/docker-buildx
28-
- run: docker buildx version
29-
- run: docker context create buildctx
30-
- run: docker buildx create --use buildctx && docker buildx inspect --bootstrap
31-
- run: GROUP_INDEX=$CIRCLE_NODE_INDEX GROUP_TOTAL=$CIRCLE_NODE_TOTAL docker buildx bake cross --progress=plain
32-
- store_artifacts:
33-
path: /work/build
34-
355
test:
366
working_directory: /work
377
docker: [{image: 'docker:20.10-git'}]
@@ -112,6 +82,5 @@ workflows:
11282
version: 2
11383
ci:
11484
jobs:
115-
- cross
11685
- test
11786
- validate

.github/workflows/build.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- 'master'
8+
- '[0-9]+.[0-9]{2}'
9+
tags:
10+
- 'v*'
11+
pull_request:
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
target:
20+
- cross
21+
- dynbinary-cross
22+
steps:
23+
-
24+
name: Checkout
25+
uses: actions/checkout@v2
26+
-
27+
name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v1
29+
-
30+
name: Run ${{ matrix.target }}
31+
uses: docker/bake-action@v1
32+
with:
33+
targets: ${{ matrix.target }}
34+
-
35+
name: Flatten artifacts
36+
working-directory: ./build
37+
run: |
38+
for dir in */; do
39+
base=$(basename "$dir")
40+
echo "Creating ${base}.tar.gz ..."
41+
tar -cvzf "${base}.tar.gz" "$dir"
42+
rm -rf "$dir"
43+
done
44+
-
45+
name: Upload artifacts
46+
uses: actions/upload-artifact@v2
47+
with:
48+
name: ${{ matrix.target }}
49+
path: ./build/*
50+
if-no-files-found: error

Makefile

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#
44
all: binary
55

6-
76
_:=$(shell ./scripts/warn-outside-container $(MAKECMDGOALS))
87

98
.PHONY: clean
@@ -21,22 +20,26 @@ test: test-unit ## run tests
2120
test-coverage: ## run test coverage
2221
gotestsum -- -coverprofile=coverage.txt $(shell go list ./... | grep -vE '/vendor/|/e2e/')
2322

23+
.PHONY: lint
24+
lint: ## run all the lint tools
25+
golangci-lint run
26+
27+
.PHONY: shellcheck
28+
shellcheck: ## run shellcheck validation
29+
find scripts/ contrib/completion/bash -type f | grep -v scripts/winresources | grep -v '.*.ps1' | xargs shellcheck
30+
2431
.PHONY: fmt
2532
fmt:
2633
go list -f {{.Dir}} ./... | xargs gofmt -w -s -d
2734

2835
.PHONY: binary
29-
binary:
30-
docker buildx bake binary
36+
binary: ## build executable for Linux
37+
./scripts/build/binary
3138

3239
.PHONY: plugins
3340
plugins: ## build example CLI plugins
3441
./scripts/build/plugins
3542

36-
.PHONY: cross
37-
cross:
38-
docker buildx bake cross
39-
4043
.PHONY: plugins-windows
4144
plugins-windows: ## build example CLI plugins for Windows
4245
./scripts/build/plugins-windows
@@ -45,10 +48,6 @@ plugins-windows: ## build example CLI plugins for Windows
4548
plugins-osx: ## build example CLI plugins for macOS
4649
./scripts/build/plugins-osx
4750

48-
.PHONY: dynbinary
49-
dynbinary: ## build dynamically linked binary
50-
USE_GLIBC=1 docker buildx bake dynbinary
51-
5251
vendor: vendor.conf ## check that vendor matches vendor.conf
5352
rm -rf vendor
5453
bash -c 'vndr |& grep -v -i clone | tee ./vndr.log'

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,46 @@ Development
1414

1515
Build CLI from source:
1616

17-
```
17+
```console
1818
$ docker buildx bake
1919
```
2020

2121
Build binaries for all supported platforms:
2222

23-
```
23+
```console
2424
$ docker buildx bake cross
2525
```
2626

2727
Build for a specific platform:
2828

29-
```
29+
```console
3030
$ docker buildx bake --set binary.platform=linux/arm64
3131
```
3232

3333
Build dynamic binary for glibc or musl:
3434

35-
```
35+
```console
3636
$ USE_GLIBC=1 docker buildx bake dynbinary
3737
```
3838

3939

4040
Run all linting:
4141

42-
```
43-
$ make -f docker.Makefile lint
42+
```console
43+
$ docker buildx bake lint shellcheck
4444
```
4545

4646
List all the available targets:
4747

48-
```
48+
```console
4949
$ make help
5050
```
5151

5252
### In-container development environment
5353

5454
Start an interactive development environment:
5555

56-
```
56+
```console
5757
$ make -f docker.Makefile shell
5858
```
5959

docker-bake.hcl

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,16 @@ target "dynbinary" {
3232
}
3333
}
3434

35-
variable "GROUP_TOTAL" {
36-
default = "1"
37-
}
38-
39-
variable "GROUP_INDEX" {
40-
default = "0"
41-
}
42-
43-
function "platforms" {
44-
params = [USE_GLIBC]
45-
result = concat(["linux/amd64", "linux/386", "linux/arm64", "linux/arm", "linux/ppc64le", "linux/s390x", "darwin/amd64", "darwin/arm64", "windows/amd64", "windows/arm", "windows/386"], USE_GLIBC!=""?[]:["windows/arm64"])
46-
}
47-
48-
function "glen" {
49-
params = [platforms, GROUP_TOTAL]
50-
result = ceil(length(platforms)/GROUP_TOTAL)
51-
}
52-
53-
target "_all_platforms" {
54-
platforms = slice(platforms(USE_GLIBC), GROUP_INDEX*glen(platforms(USE_GLIBC), GROUP_TOTAL),min(length(platforms(USE_GLIBC)), (GROUP_INDEX+1)*glen(platforms(USE_GLIBC), GROUP_TOTAL)))
35+
target "platforms" {
36+
platforms = concat(["linux/amd64", "linux/386", "linux/arm64", "linux/arm", "linux/ppc64le", "linux/s390x", "darwin/amd64", "darwin/arm64", "windows/amd64", "windows/arm", "windows/386"], USE_GLIBC!=""?[]:["windows/arm64"])
5537
}
5638

5739
target "cross" {
58-
inherits = ["binary", "_all_platforms"]
40+
inherits = ["binary", "platforms"]
5941
}
6042

6143
target "dynbinary-cross" {
62-
inherits = ["dynbinary", "_all_platforms"]
44+
inherits = ["dynbinary", "platforms"]
6345
}
6446

6547
target "lint" {

docker.Makefile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ build_e2e_image:
4242
DOCKER_RUN_NAME_OPTION := $(if $(DOCKER_CLI_CONTAINER_NAME),--name $(DOCKER_CLI_CONTAINER_NAME),)
4343
DOCKER_RUN := docker run --rm $(ENVVARS) $(DOCKER_CLI_MOUNTS) $(DOCKER_RUN_NAME_OPTION)
4444

45-
binary: build_binary_native_image ## build the CLI
46-
$(DOCKER_RUN) $(BINARY_NATIVE_IMAGE_NAME)
45+
.PHONY: binary
46+
binary:
47+
docker buildx bake binary
4748

4849
build: binary ## alias for binary
4950

@@ -62,6 +63,10 @@ test-unit: build_docker_image ## run unit tests (using go test)
6263
.PHONY: test ## run unit and e2e tests
6364
test: test-unit test-e2e
6465

66+
.PHONY: cross
67+
cross:
68+
docker buildx bake cross
69+
6570
.PHONY: plugins-windows
6671
plugins-windows: build_cross_image ## build the example CLI plugins for Windows
6772
$(DOCKER_RUN) $(CROSS_IMAGE_NAME) make $@
@@ -70,6 +75,10 @@ plugins-windows: build_cross_image ## build the example CLI plugins for Windows
7075
plugins-osx: build_cross_image ## build the example CLI plugins for macOS
7176
$(DOCKER_RUN) $(CROSS_IMAGE_NAME) make $@
7277

78+
.PHONY: dynbinary
79+
dynbinary: ## build dynamically linked binary
80+
USE_GLIBC=1 docker buildx bake dynbinary
81+
7382
.PHONY: dev
7483
dev: build_docker_image ## start a build container in interactive mode for in-container development
7584
$(DOCKER_RUN) -it \
@@ -82,6 +91,10 @@ shell: dev ## alias for dev
8291
lint: ## run linters
8392
docker buildx bake lint
8493

94+
.PHONY: shellcheck
95+
shellcheck: ## run shellcheck validation
96+
docker buildx bake shellcheck
97+
8598
.PHONY: fmt
8699
fmt: ## run gofmt
87100
$(DOCKER_RUN) $(DEV_DOCKER_IMAGE_NAME) make fmt
@@ -102,10 +115,6 @@ manpages: build_docker_image ## generate man pages from go source and markdown
102115
yamldocs: build_docker_image ## generate documentation YAML files consumed by docs repo
103116
$(DOCKER_RUN) -it $(DEV_DOCKER_IMAGE_NAME) make yamldocs
104117

105-
.PHONY: shellcheck
106-
shellcheck: ## run shellcheck validation
107-
docker buildx bake shellcheck
108-
109118
.PHONY: test-e2e
110119
test-e2e: test-e2e-non-experimental test-e2e-experimental test-e2e-connhelper-ssh ## run all e2e tests
111120

dockerfiles/Dockerfile.cross

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)