-
Notifications
You must be signed in to change notification settings - Fork 214
85 lines (78 loc) · 2.24 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# every push to a branch: build binary
name: Build
on:
pull_request:
types: [opened, synchronize]
jobs:
build_binary:
name: Build shell-operator binary
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Check out shell-operator code
uses: actions/checkout@v4
- name: Restore Go modules
id: go-modules-cache
uses: actions/[email protected]
with:
path: |
~/go/pkg/mod
key: ${{ runner.os }}-gomod-${{ hashFiles('go.mod', 'go.sum') }}
- name: Download Go modules
if: steps.go-modules-cache.outputs.cache-hit != 'true'
run: |
go mod download
echo -n "Go modules unpacked size is: " && du -sh $HOME/go/pkg/mod
- name: Download prebuilt libjq static libraries
run: |
curl -sSfL https://github.com/flant/libjq-go/releases/download/jq-b6be13d5-0/libjq-glibc-amd64.tgz | tar zxf -
- name: Build binary
run: |
export CGO_ENABLED=1
export CGO_CFLAGS="-I$GITHUB_WORKSPACE/libjq/include"
export CGO_LDFLAGS="-L$GITHUB_WORKSPACE/libjq/lib"
export GOOS=linux
go build -tags use_libjq ./cmd/shell-operator
# MacOS build works fine because jq package already has static libraries.
# Windows build requires jq compilation, this should be done in libjq-go.
# TODO Does cross-compile can help here?
#
# build_darwin_binary:
# name: Darwin binary
# runs-on: macos-10.15
# steps:
# - uses: actions/checkout@v4
#
# - name: install jq
# run: |
# brew install jq
#
# - name: build shell-operator binary
# run: |
# GO111MODULE=on \
# CGO_ENABLED=1 \
# go build ./cmd/shell-operator
#
# file ./shell-operator
#
# ./shell-operator version
#
# build_windows_binary:
# name: Windows binary
# runs-on: windows-2019
# steps:
# - uses: actions/checkout@v4
#
# - name: build shell-operator binary
# run: |
# GO111MODULE=on \
# CGO_ENABLED=1 \
# go build ./cmd/shell-operator
#
# ls -la .
#
# ./shell-operator.exe version
# shell: bash