-
Notifications
You must be signed in to change notification settings - Fork 3
144 lines (137 loc) · 4.21 KB
/
ci.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: ci
on:
push:
branches:
- master
tags:
- '**'
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
.go/.cache
.go/pkg
key: ${{ runner.os }}-go-${{ github.sha }}
restore-keys: |
${{ runner.os }}-go-
- name: Build binaries
run: |
make all-build
make checksums
- name: Tar binaries
run: |
tar -cvf binaries.tar .go/bin
- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: binaries-${{ github.sha }}
path: |
binaries.tar
test:
runs-on: ubuntu-latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- uses: actions/checkout@v1
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
.go/.cache
.go/pkg
key: ${{ runner.os }}-go-${{ github.sha }}
restore-keys: |
${{ runner.os }}-go-
- name: Code Coverage
run: |
make test
bash <(curl -s https://codecov.io/bash)
docker:
needs: [build, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
# Ensure the same binaries are used from the build job
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: binaries-${{ github.sha }}
- name: Untar binaries
run: |
tar -xvf binaries.tar
- name: Login to docker registry
if: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }}
env:
DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin
- name: Build and push image
env:
DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
run: |
make buildx-image "REGISTRY_USER=$DOCKERHUB_REGISTRY_USER" "BUILDX_TAG_LATEST=${{ startsWith(github.ref, 'refs/tags/') }}" "BUILDX_PUSH=${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }}"
update-draft-release:
needs: [build,test,docker]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- id: release-drafter
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
needs: [build,test,docker]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- id: release-drafter
uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: false
name: ${{ github.ref_name }}
tag: ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Ensure the same binaries are used from the build job
- name: Download binaries
uses: actions/download-artifact@v3
with:
name: binaries-${{ github.sha }}
- name: Untar binaries
run: |
tar -xvf binaries.tar
# Upload binaries and publish
- uses: softprops/action-gh-release@v1
with:
draft: false
name: ${{ steps.release-drafter.outputs.name }}
tag_name: ${{ steps.release-drafter.outputs.tag_name }}
body: ${{ steps.release-drafter.outputs.body }}
files: |
.go/bin/*
update-dockerhub-description:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
repository: ${{ github.repository }}
short-description: ${{ github.event.repository.description }}