-
Notifications
You must be signed in to change notification settings - Fork 1
137 lines (126 loc) · 4.33 KB
/
ci-release.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
name: Release
on:
push:
branches: [ "main" ]
tags:
- '*'
jobs:
go-unit-test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.22.2
- name: Test
run: make test
- uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
files: ./cover.out # optional
flags: unittests # optional
name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
docker-build:
runs-on: ubuntu-latest
needs: [go-unit-test]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login Github Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta Controller
id: controller_meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/baizeai/kcover-controller
tags: |
type=semver,pattern={{raw}}
- name: Docker meta Agent
id: agent_meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/baizeai/kcover-agent
tags: |
type=semver,pattern={{raw}}
- name: Build Image Controller
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
provenance: false
tags: ${{ steps.controller_meta.outputs.tags }}
labels: ${{ steps.controller_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: docker/controller.Dockerfile
- name: Build Image Agent
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
provenance: false
tags: ${{ steps.agent_meta.outputs.tags }}
labels: ${{ steps.agent_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: docker/agent.Dockerfile
publish-chart:
if: startsWith(github.ref, 'refs/tags/v')
needs: [ docker-build ]
permissions:
contents: write
env:
HELM_CHARTS_DIR: manifests/kcover
HELM_CHART_NAME: kcover
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Helm
uses: azure/setup-helm@v3
- name: Get the version
id: get_version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
- name: Tag helm chart image
run: |
image_tag=${{ steps.get_version.outputs.VERSION }}
chart_version=${{ steps.get_version.outputs.VERSION }}
sed -i "s/latest/${image_tag}/g" $HELM_CHARTS_DIR/values.yaml
chart_smever=${chart_version#"v"}
sed -i "s/0.1.0/${chart_smever}/g" $HELM_CHARTS_DIR/Chart.yaml
- uses: getsentry/action-github-app-token@v2
id: get_app_token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Sync Chart Repo
run: |
git config --global user.email "baize.ai[bot]@users.noreply.github.com"
git config --global user.name "baize.ai[bot]"
git clone https://x-access-token:${{ steps.get_app_token.outputs.token }}@github.com/BaizeAI/charts.git baize-charts
helm package $HELM_CHARTS_DIR --destination ./baize-charts/docs/
helm repo index --url https://baizeai.github.io/charts ./baize-charts/docs/
cd baize-charts/
git add docs/
chart_version=${{ steps.get_version.outputs.VERSION }}
chart_smever=${chart_version#"v"}
git commit -m "update kcover chart ${chart_smever}"
git push https://x-access-token:${{ steps.get_app_token.outputs.token }}@github.com/BaizeAI/charts.git