Skip to content
This repository was archived by the owner on May 24, 2023. It is now read-only.

Commit 9342503

Browse files
authored
Remove Go version from CI, add trimpath and ldflags (#96)
1 parent 6b987fc commit 9342503

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

.github/workflows/ci.yml

+12-9
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,23 @@ on:
2525

2626
env:
2727
DOCKER_BUILDKIT: 1
28-
GOLANG_VERSION: 1.16
2928

3029
jobs:
3130

3231
binary:
3332
name: Build Binary
34-
runs-on: ubuntu-18.04
33+
runs-on: ubuntu-20.04
3534
steps:
3635
- name: Checkout Repository
3736
uses: actions/checkout@v2
37+
- name: Determine Go version from go.mod
38+
run: echo "GO_VERSION=$(grep "go 1." go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
39+
- name: Setup Golang Environment
40+
uses: actions/setup-go@v2
41+
with:
42+
go-version: ${{ env.GO_VERSION }}
3843
- name: Build Binary
3944
run: make binary
40-
env:
41-
GOFLAGS: '-gcflags=-trimpath=${{ github.workspace }} -asmflags=-trimpath=${{ github.workspace }}'
4245
- name: Cache Artifacts
4346
uses: actions/[email protected]
4447
with:
@@ -47,20 +50,20 @@ jobs:
4750

4851
unit-tests:
4952
name: Unit Tests
50-
runs-on: ubuntu-18.04
53+
runs-on: ubuntu-20.04
5154
steps:
5255
- name: Checkout Repository
5356
uses: actions/checkout@v2
5457
- name: Setup Golang Environment
5558
uses: actions/setup-go@v2
5659
with:
57-
go-version: '${{ env.GOLANG_VERSION }}'
60+
go-version: ${{ env.GO_VERSION }}
5861
- name: Run Tests
5962
run: make test
6063

6164
build:
6265
name: Build Image
63-
runs-on: ubuntu-18.04
66+
runs-on: ubuntu-20.04
6467
needs: [binary, unit-tests]
6568
steps:
6669
- name: Checkout Repository
@@ -93,7 +96,7 @@ jobs:
9396

9497
release-docker:
9598
name: Release Image
96-
runs-on: ubuntu-18.04
99+
runs-on: ubuntu-20.04
97100
needs: [build, unit-tests]
98101
if:
99102
github.repository == 'nginxinc/nginx-ingress-operator' &&
@@ -138,7 +141,7 @@ jobs:
138141

139142
notify:
140143
name: Notify
141-
runs-on: ubuntu-18.04
144+
runs-on: ubuntu-20.04
142145
needs: release-docker
143146
if: always() && github.ref == 'refs/heads/master'
144147
steps:

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ test:
77
GO111MODULE=on go test ./...
88

99
binary:
10-
CGO_ENABLED=0 GO111MODULE=on GOOS=linux go build -trimpath -installsuffix cgo -o build/_output/bin/nginx-ingress-operator github.com/nginxinc/nginx-ingress-operator/cmd/manager
10+
$(eval GOPATH=$(shell go env GOPATH))
11+
CGO_ENABLED=0 GO111MODULE=on GOFLAGS="-gcflags=-trimpath=${GOPATH} -asmflags=-trimpath=${GOPATH}" GOOS=linux go build -trimpath -ldflags "-s -w" -o build/_output/bin/nginx-ingress-operator github.com/nginxinc/nginx-ingress-operator/cmd/manager
1112

1213
build: binary
1314
docker build -f build/Dockerfile -t $(IMAGE):$(TAG) .

0 commit comments

Comments
 (0)