Skip to content

Commit b334468

Browse files
committed
chore(workflow): add build.yml
Longhron 9460 Signed-off-by: Derek Su <derek.su@suse.com>
1 parent b0b3a19 commit b334468

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

.github/workflows/build.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: build
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- v*
7+
tags:
8+
- v*
9+
pull_request:
10+
workflow_dispatch:
11+
jobs:
12+
build:
13+
name: Build binaries
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Build binaries
20+
run: make
21+
22+
- uses: codecov/codecov-action@v4
23+
with:
24+
files: ./coverage.out
25+
flags: unittests
26+
token: ${{ secrets.CODECOV_TOKEN }}
27+
28+
- name: Upload binaries
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: binaries_artifact
32+
path: ./bin/*
33+
34+
build_push_image:
35+
name: Build and push image
36+
runs-on: ubuntu-latest
37+
needs: build
38+
if: ${{ startsWith(github.ref, 'refs/heads/') || startsWith(github.ref, 'refs/tags/') }}
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v4
42+
43+
- name: Download binaries
44+
uses: actions/download-artifact@v4
45+
with:
46+
name: binaries_artifact
47+
path: ./bin/
48+
49+
- name: Add executable permission
50+
run: |
51+
chmod +x ./bin/*
52+
53+
- name: Copy bin folder to package
54+
run: |
55+
cp -r ./bin ./package/
56+
57+
# For multi-platform support
58+
- name: Set up QEMU
59+
uses: docker/setup-qemu-action@v3
60+
- name: Set up Docker Buildx
61+
uses: docker/setup-buildx-action@v3
62+
63+
- name: Declare branch
64+
run: |
65+
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> "$GITHUB_ENV"
66+
67+
- name: Login to Docker Hub
68+
uses: docker/login-action@v3
69+
with:
70+
username: ${{ secrets.DOCKER_USERNAME }}
71+
password: ${{ secrets.DOCKER_PASSWORD }}
72+
73+
# longhornio/kbench image
74+
- name: docker-publish
75+
if: ${{ startsWith(github.ref, 'refs/heads/') }}
76+
uses: docker/build-push-action@v5
77+
with:
78+
context: ./
79+
push: true
80+
platforms: linux/amd64,linux/arm64
81+
tags: longhornio/kbench:${{ env.branch }}-head
82+
file: package/Dockerfile
83+
84+
- name: docker-publish-with-tag
85+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
86+
uses: docker/build-push-action@v5
87+
with:
88+
context: ./
89+
push: true
90+
platforms: linux/amd64,linux/arm64
91+
tags: longhornio/kbench:${{ github.ref_name }}
92+
file: package/Dockerfile
93+

0 commit comments

Comments
 (0)