-
Notifications
You must be signed in to change notification settings - Fork 0
308 lines (266 loc) Β· 10.9 KB
/
release.yml
File metadata and controls
308 lines (266 loc) Β· 10.9 KB
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
packages: write
id-token: write
env:
GO_VERSION: "1.25"
REGISTRY: docker.io
IMAGE_NAME: supporttools/node-doctor
jobs:
# Build and push Docker images
docker:
name: Build & Push Docker Images
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ !contains(github.ref_name, 'rc') && !contains(github.ref_name, 'beta') && !contains(github.ref_name, 'alpha') }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
GIT_COMMIT=${{ github.sha }}
BUILD_TIME=${{ github.event.head_commit.timestamp }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Install cosign
uses: sigstore/cosign-installer@v3
with:
cosign-release: "v2.2.2"
- name: Sign Docker image
env:
COSIGN_EXPERIMENTAL: 1
run: |
# Extract version without 'v' prefix (to match docker metadata output)
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
echo "Signing Docker image with cosign (keyless)..."
echo "Tag: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}"
cosign sign --yes ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}
echo "β
Docker image signed"
- name: Generate Docker summary
run: |
echo "## π³ Docker Images" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tag:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Images Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Platforms:** linux/amd64, linux/arm64" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Pull Command" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# Create GitHub Release
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: docker
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate release notes
id: release-notes
run: |
cat << 'EOF' > release-notes.md
## Node Doctor ${{ github.ref_name }}
Kubernetes node health monitoring and auto-remediation DaemonSet.
### π Quick Start
**Docker (Recommended):**
```bash
docker pull supporttools/node-doctor:${{ github.ref_name }}
```
**Helm Chart:**
```bash
helm repo add supporttools https://charts.support.tools
helm repo update
helm install node-doctor supporttools/node-doctor \
--namespace node-doctor \
--create-namespace
```
**Kubernetes Manifests:**
```bash
kubectl apply -f https://raw.githubusercontent.com/supporttools/node-doctor/${{ github.ref_name }}/deployment/rbac.yaml
kubectl apply -f https://raw.githubusercontent.com/supporttools/node-doctor/${{ github.ref_name }}/deployment/daemonset.yaml
```
### π¦ Available Artifacts
- **Docker Images:** `supporttools/node-doctor:${{ github.ref_name }}` (linux/amd64, linux/arm64)
- **Helm Chart:** Available at https://charts.support.tools
### π Documentation
- [Deployment Guide](https://github.com/supporttools/node-doctor/blob/main/docs/deployment.md)
- [Configuration Reference](https://github.com/supporttools/node-doctor/blob/main/docs/configuration.md)
- [Monitor Specifications](https://github.com/supporttools/node-doctor/blob/main/docs/monitors.md)
### π Reporting Issues
Found a bug? [Open an issue](https://github.com/supporttools/node-doctor/issues/new)
EOF
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
body_path: release-notes.md
draft: false
prerelease: ${{ contains(github.ref_name, 'rc') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') }}
files: |
deployment/rbac.yaml
deployment/daemonset.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Helm Chart Publishing
helm-publish:
name: Publish Helm Chart
runs-on: ubuntu-latest
needs: docker
outputs:
chart-version: ${{ steps.get-chart-version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install envsubst
run: |
sudo apt-get update
sudo apt-get install -y gettext-base
- name: Set up Helm
uses: azure/setup-helm@v4.2.0
- name: Determine Chart Version
id: get-chart-version
run: |
# Remove 'v' prefix for Helm chart version
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Prepare Helm chart files
run: |
rm -f helm/node-doctor/Chart.yaml helm/node-doctor/values.yaml
export CHART_VERSION="${{ steps.get-chart-version.outputs.version }}"
export APP_VERSION="${{ github.ref_name }}"
export IMAGE_TAG="${{ github.ref_name }}"
envsubst < helm/node-doctor/Chart.yaml.template > helm/node-doctor/Chart.yaml
envsubst < helm/node-doctor/values.yaml.template > helm/node-doctor/values.yaml
echo "=== Chart.yaml ==="
cat helm/node-doctor/Chart.yaml
- name: Helm Lint
run: |
# Copy chart to temp directory to avoid directory context issues
cp -r helm/node-doctor /tmp/chart-lint
helm lint /tmp/chart-lint/
rm -rf /tmp/chart-lint
- name: Package Helm chart
run: |
mkdir -p helm/repo
helm package helm/node-doctor --destination helm/repo
ls -la helm/repo/
- name: Checkout helm-chart repository
uses: actions/checkout@v4
with:
repository: SupportTools/helm-chart
path: helm-chart
token: ${{ secrets.BOT_TOKEN }}
- name: Configure Git
run: |
git config --global user.email "github-action@users.noreply.github.com"
git config --global user.name "GitHub Action"
- name: Update Helm repository
run: |
cp helm/repo/node-doctor-*.tgz helm-chart/
cd helm-chart
helm repo index . --url https://charts.support.tools/
git add .
git commit -m "Update Node Doctor Helm chart ${{ steps.get-chart-version.outputs.version }}"
git push
- name: Verify Chart Availability
run: |
helm repo add charts https://charts.support.tools/
MAX_TRIES=30
SLEEP_TIME=10
COUNTER=0
CHART_VERSION="${{ steps.get-chart-version.outputs.version }}"
while [ $COUNTER -lt $MAX_TRIES ]; do
helm repo update
if helm search repo charts/node-doctor --version $CHART_VERSION | grep -q $CHART_VERSION; then
echo "β
Chart node-doctor version $CHART_VERSION found in repository"
exit 0
fi
echo "Waiting for chart to become available... (Attempt $((COUNTER+1))/$MAX_TRIES)"
sleep $SLEEP_TIME
let COUNTER=COUNTER+1
done
echo "β Chart did not become available within the timeout period"
exit 1
- name: Add Helm chart to release summary
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "### π¦ Helm Chart" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Chart Version:** ${{ steps.get-chart-version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Repository:** https://charts.support.tools/" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Install with:" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "helm repo add supporttools https://charts.support.tools" >> $GITHUB_STEP_SUMMARY
echo "helm repo update" >> $GITHUB_STEP_SUMMARY
echo "helm install node-doctor supporttools/node-doctor --namespace node-doctor --create-namespace" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
# Summary job
release-complete:
name: Release Complete
runs-on: ubuntu-latest
needs: [docker, github-release, helm-publish]
if: always()
steps:
- name: Check release status
run: |
if [[ "${{ needs.docker.result }}" != "success" ]]; then
echo "β Docker build job failed"
exit 1
fi
if [[ "${{ needs.github-release.result }}" != "success" ]]; then
echo "β GitHub release job failed"
exit 1
fi
if [[ "${{ needs.helm-publish.result }}" != "success" ]]; then
echo "β Helm publish job failed"
exit 1
fi
echo "β
Release ${{ github.ref_name }} completed successfully!"
echo ""
echo "Next steps:"
echo "1. Verify release: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}"
echo "2. Test Docker image: docker pull supporttools/node-doctor:${{ github.ref_name }}"
echo "3. Test Helm chart: helm install node-doctor supporttools/node-doctor"
echo "4. Update documentation if needed"
echo "5. Announce release to users"