-
Notifications
You must be signed in to change notification settings - Fork 4
114 lines (101 loc) · 2.97 KB
/
push.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: pushCI
on:
push:
branches:
- master
- release/v*
tags:
- 'v*'
jobs:
build-linux:
name: Build
strategy:
matrix:
go-version: [1.18]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/setup-go@v1
with:
go-version: 1.18
- uses: actions/checkout@v1
- name: Build
run: make all
- name: Test
run: |
make test
shell: bash
build-windows:
name: Build
strategy:
matrix:
go-version: [1.18]
platform: [windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/setup-go@v1
with:
go-version: 1.18
- uses: actions/checkout@v1
- name: Build
env:
GO111MODULE: "on"
run: make all
binaries:
name: Build binaries and notarize sources
needs:
- build-windows
- build-linux
runs-on: ubuntu-latest
env:
JOB_NAME: ${{ github.job }}
JOB_ID: ${{ github.run_id }}
outputs:
matrix: ${{ steps.list-binaries.outputs.matrix }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v3
- name: Build binaries
run: make dist
- id: list-binaries
run: |
echo "::set-output name=matrix::$(ls dist | jq -R -s -c 'split("\n")[:-1] | {binary: .}')"
- name: Upload binary artifacts
uses: actions/upload-artifact@v3
with:
name: immugw-binaries
path: dist
retention-days: 5
- name: Calculate checksums
run: make dist/binary.md
images:
name: Build and notarize Docker Images
needs:
- binaries
runs-on: ubuntu-latest
env:
JOB_NAME: ${{ github.job }}
JOB_ID: ${{ github.run_id }}
DOCKER_IMAGE_IMMUGW: "codenotary/immugw"
DOCKER_BUILDKIT: "1"
steps:
- uses: actions/checkout@v3
- name: Build docker images
shell: bash
run: |
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
VERSION_TAG="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}.${BASH_REMATCH[3]}"
VERSION_TAG_SHORT="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"
fi
docker build --tag "${DOCKER_IMAGE_IMMUGW}:dev" -f Dockerfile .
echo "${{ secrets.DOCKER_HUB_REGISTRY_PASS }}" | docker login -u "${{ secrets.DOCKER_HUB_REGISTRY_USER }}" --password-stdin
docker push "${DOCKER_IMAGE_IMMUGW}:dev"
if [[ ! -z "$VERSION_TAG" ]]; then
for tag in "${VERSION_TAG}" "${VERSION_TAG_SHORT}" "latest"; do
docker tag "${DOCKER_IMAGE_IMMUGW}:dev" "${DOCKER_IMAGE_IMMUGW}:${tag}"
docker push "${DOCKER_IMAGE_IMMUGW}:${tag}"
done
fi
docker logout