-
Notifications
You must be signed in to change notification settings - Fork 72
203 lines (187 loc) · 7.19 KB
/
release.yaml
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# Reference from:
# https://goreleaser.com/ci/actions/
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
pull-requests: write
jobs:
Test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Running go tests with coverage
env:
GO111MODULE: on
run: make cover
GolangLint:
name: Golang Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.62.0
skip-cache: true
args: >
--timeout=10m
--verbose
--max-issues-per-linter=0
--max-same-issues=0
# Lints Pull Request commits with commitlint.
#
# Rules can be referenced:
# https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional
CommitLint:
name: Commit Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
# Release the artifacts, release note and images.
Release:
runs-on: ubuntu-latest
# needs: [Test, GolangLint, CommitLint]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if on tag
run: |
if [[ "${GITHUB_REF#refs/tags/}" != "$GITHUB_REF" ]]; then
echo "Running on tag ${GITHUB_REF#refs/tags/}"
else
echo "Not running on a tag"
fi
- name: Get version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install npm packages and build UI
working-directory: ./ui
run: |
npm install
# Using 'CI=false' prevents build errors due to warnings.
# It bypasses the 'process.env.CI = true' setting in CI environments
# that treats warnings as errors, ensuring a successful build.
CI=false npm run build
touch build/.gitkeep
- name: Determine GoReleaser Config with Regex
run: |
tag=${GITHUB_REF#refs/tags/}
alpha='v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
beta='v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
rc='v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
release='v[0-9]+.[0-9]+.[0-9]+'
if [[ $tag =~ $alpha ]] || [[ $tag =~ $beta ]]; then
echo "Match found for alpha or beta tag"
echo "GO_RELEASER_CONFIG=.goreleaser-dev.yml" >> $GITHUB_ENV
elif [[ $tag =~ $rc ]] || [[ $tag =~ $release ]]; then
echo "Match found for rc or release tag"
echo "GO_RELEASER_CONFIG=.goreleaser.yml" >> $GITHUB_ENV
else
echo "No match found"
exit 1
fi
- name: Release the karpor with GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --clean --config .goreleaser/${{ env.GO_RELEASER_CONFIG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get new chart version from the chart repo
id: get_chart_version
run: |
helm repo add kusionstack https://kusionstack.github.io/charts
helm repo update
version=$(helm search repo kusionstack/karpor --versions | head -n 2 | tail -n 1 | awk '{print $2}')
if [ -z "$version" ]; then
echo "Error: Unable to fetch chart version" >&2
exit 1
fi
echo "Current chart version is: $version"
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
patch=$(echo "$version" | cut -d. -f3)
new_chart_version="${major}.${minor}.$((patch + 1))"
echo "New chart version is: $new_chart_version"
# Calculate appVersion by removing 'v' prefix from VERSION
new_app_version="${{ steps.get_version.outputs.VERSION }}"
new_app_version="${new_app_version#v}"
echo "New app version is: $new_app_version"
echo "::set-output name=new_chart_version::$new_chart_version"
echo "::set-output name=new_app_version::$new_app_version"
- name: Checkout Target repository
uses: actions/checkout@v4
with:
repository: KusionStack/charts
path: charts
token: ${{ secrets.CHART_UPDATER_PAT }}
fetch-depth: 0
- name: Bump version in the related HelmChart Chart.yaml
uses: fjogeleit/yaml-update-action@main
env:
COMMIT_MESSAGE: 'chore(karpor): bump app version to ${{ steps.get_chart_version.outputs.new_app_version }}, chart version to ${{ steps.get_chart_version.outputs.new_chart_version }}'
with:
repository: KusionStack/charts
valueFile: 'charts/karpor/Chart.yaml'
changes: '{"version":"${{ steps.get_chart_version.outputs.new_chart_version }}", "appVersion":"${{ steps.get_chart_version.outputs.new_app_version }}"}'
value: ${{ steps.get_chart_version.outputs.new_app_version }}
branch: bump-karpor-to-${{ steps.get_chart_version.outputs.new_app_version }}
targetBranch: master
message: ${{ env.COMMIT_MESSAGE }}
createPR: true
title: ${{ env.COMMIT_MESSAGE }}
description: |
This PR updates the Karpor Helm chart with the following changes:
- Bump the `appVersion` to `${{ steps.get_chart_version.outputs.new_app_version }}`
- Bump the `version` to `${{ steps.get_chart_version.outputs.new_chart_version }}`
These updates ensure that the chart reflects the latest Karpor release.
**Note**: This PR was automatically generated by the **karpor-chart-updater[bot]**.
labels: 'karpor-chart-updater[bot]'
token: ${{ secrets.CHART_UPDATER_PAT }}
workDir: charts
- name: Log Test Outputs # Log outputs for debugging
run: |
echo "Testing complete. Check the logs for details."
echo "New chart version: ${{ steps.get_chart_version.outputs.new_chart_version }}"
echo "New app version: ${{ steps.get_chart_version.outputs.new_app_version }}"