forked from rimusz-lab/stern
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (79 loc) · 3.35 KB
/
test_build.yml
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
86
87
88
89
90
91
92
93
94
name: Go
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: go mod download
- name: Test
run: go test -v .
- name: Build docker image
run: |
docker login ghcr.io --username derdanne --password "${{ secrets.GHCR_TOKEN }}"
docker build . -t ghcr.io/derdanne/stern:$(echo ${GITHUB_REF#refs/} | sed 's/\//_/g')
docker push ghcr.io/derdanne/stern:$(echo ${GITHUB_REF#refs/} | sed 's/\//_/g')
- name: Build linux amd64
run: |
mkdir -p artifacts/latest/linux_amd64
export CGO_ENABLED=0
GOOS=linux GOARCH=amd64 go build \
-ldflags="-s -X github.com/derdanne/stern.GitCommit=${GITHUB_SHA::8} -X github.com/derdanne/stern.PatchVersion=$(( ($(date +%s) - $(date --date=20150101 +%s) )/(60*60*24) )) -X github.com/derdanne/stern.Compiled=$(date +%s)" \
-installsuffix cgo \
-o artifacts/latest/linux_amd64/stern
- name: Build darwin amd64
run: |
mkdir -p artifacts/latest/darwin_amd64
export CGO_ENABLED=0
GOOS=darwin GOARCH=amd64 go build \
-ldflags="-s -X github.com/derdanne/stern.GitCommit=${GITHUB_SHA::8} -X github.com/derdanne/stern.PatchVersion=$(( ($(date +%s) - $(date --date=20150101 +%s) )/(60*60*24) )) -X github.com/derdanne/stern.Compiled=$(date +%s)" \
-installsuffix cgo \
-o artifacts/latest/darwin_amd64/stern
- name: Build darwin arm64
run: |
mkdir -p artifacts/latest/darwin_arm64
export CGO_ENABLED=0
GOOS=darwin GOARCH=arm64 go build \
-ldflags="-s -X github.com/derdanne/stern.GitCommit=${GITHUB_SHA::8} -X github.com/derdanne/stern.PatchVersion=$(( ($(date +%s) - $(date --date=20150101 +%s) )/(60*60*24) )) -X github.com/derdanne/stern.Compiled=$(date +%s)" \
-installsuffix cgo \
-o artifacts/latest/darwin_arm64/stern
- name: Build windows amd64
run: |
mkdir -p artifacts/latest/windows_amd64
export CGO_ENABLED=0
GOOS=windows GOARCH=amd64 go build \
-ldflags="-s -X github.com/derdanne/stern.GitCommit=${GITHUB_SHA::8} -X github.com/derdanne/stern.PatchVersion=$(( ($(date +%s) - $(date --date=20150101 +%s) )/(60*60*24) )) -X github.com/derdanne/stern.Compiled=$(date +%s)" \
-installsuffix cgo \
-o artifacts/latest/windows_amd64/stern.exe
- name: Upload build linux amd64
uses: actions/upload-artifact@v1
with:
name: stern_linux_amd64
path: artifacts/latest/linux_amd64/stern
- name: Upload build darwin amd64
uses: actions/upload-artifact@v1
with:
name: stern_darwin_amd64
path: artifacts/latest/darwin_amd64/stern
- name: Upload build darwin arm64
uses: actions/upload-artifact@v1
with:
name: stern_darwin_arm64
path: artifacts/latest/darwin_arm64/stern
- name: Upload build windows amd64
uses: actions/upload-artifact@v1
with:
name: stern_windows_amd64
path: artifacts/latest/windows_amd64/stern.exe