This repository was archived by the owner on Jun 13, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
272 lines (226 loc) · 9.47 KB
/
Copy pathrelease.yml
File metadata and controls
272 lines (226 loc) · 9.47 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.2.3)'
required: true
type: string
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
PYTHON_VERSION: "3.11"
jobs:
test:
name: Run Tests Before Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install dependencies
run: uv sync --frozen
- name: Run tests
run: |
uv run pytest tests/ -v
build-and-push:
name: Build and Push Release
runs-on: ubuntu-latest
needs: test
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for git describe and changelog
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="v${{ github.event.inputs.version }}"
# Create and push the tag if it doesn't exist
if ! git rev-parse "$VERSION" >/dev/null 2>&1; then
git tag "$VERSION"
git push origin "$VERSION"
fi
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "version_number=${VERSION#v}" >> $GITHUB_OUTPUT
- name: Generate Changelog
id: changelog
run: |
# Get the previous tag
PREVIOUS_TAG=$(git describe --tags --abbrev=0 "${VERSION}^" 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
echo "No previous tag found, including all commits"
COMMIT_RANGE=""
else
echo "Generating changelog from $PREVIOUS_TAG to $VERSION"
COMMIT_RANGE="$PREVIOUS_TAG..$VERSION"
fi
# Generate changelog
{
echo "CHANGELOG<<EOF"
echo "## 🚀 What's Changed"
echo ""
# Features
FEATURES=$(git log $COMMIT_RANGE --pretty=format:"* %s (%h)" --grep="^feat" 2>/dev/null)
if [ -n "$FEATURES" ]; then
echo "### ✨ Features"
echo "$FEATURES"
echo ""
fi
# Bug fixes
FIXES=$(git log $COMMIT_RANGE --pretty=format:"* %s (%h)" --grep="^fix" 2>/dev/null)
if [ -n "$FIXES" ]; then
echo "### 🐛 Bug Fixes"
echo "$FIXES"
echo ""
fi
# Documentation
DOCS=$(git log $COMMIT_RANGE --pretty=format:"* %s (%h)" --grep="^docs" 2>/dev/null)
if [ -n "$DOCS" ]; then
echo "### 📚 Documentation"
echo "$DOCS"
echo ""
fi
# Performance
PERF=$(git log $COMMIT_RANGE --pretty=format:"* %s (%h)" --grep="^perf" 2>/dev/null)
if [ -n "$PERF" ]; then
echo "### ⚡ Performance"
echo "$PERF"
echo ""
fi
# All other commits
OTHER=$(git log $COMMIT_RANGE --pretty=format:"* %s (%h)" --grep="^feat" --grep="^fix" --grep="^docs" --grep="^perf" --invert-grep 2>/dev/null)
if [ -n "$OTHER" ]; then
echo "### 🔧 Other Changes"
echo "$OTHER"
echo ""
fi
# Contributors
echo "### 👥 Contributors"
git log $COMMIT_RANGE --pretty=format:"* @%an" | sort -u
echo ""
# Statistics
if [ -n "$COMMIT_RANGE" ]; then
echo "### 📊 Statistics"
COMMITS=$(git rev-list --count $COMMIT_RANGE)
FILES=$(git diff --stat $COMMIT_RANGE | tail -1)
echo "* $COMMITS commits"
echo "* $FILES"
fi
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Build and push with build.py
run: |
# Install Python dependencies for build script
pip install rich click semver pyyaml
# Set CI environment variable to ensure proper tagging
export CI=true
# Build and push with the specific version tag
python build.py --version-tag ${{ steps.version.outputs.version_number }}
# Additional tags for releases
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.version.outputs.version_number }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
# Create major and minor version tags
MAJOR=$(echo ${{ steps.version.outputs.version_number }} | cut -d. -f1)
MINOR=$(echo ${{ steps.version.outputs.version_number }} | cut -d. -f1,2)
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.version.outputs.version_number }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${MAJOR}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${MAJOR}
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.version.outputs.version_number }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${MINOR}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${MINOR}
- name: Generate SBOM
uses: anchore/sbom-action@v0
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.version.outputs.version_number }}
format: spdx-json
output-file: sbom.spdx.json
- name: Sign container image
env:
COSIGN_EXPERIMENTAL: 1
run: |
# Install cosign
curl -sSL https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64 -o /tmp/cosign
chmod +x /tmp/cosign
# Sign the images
/tmp/cosign sign --yes ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ steps.version.outputs.version_number }}
/tmp/cosign sign --yes ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
continue-on-error: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: Release ${{ steps.version.outputs.version }}
draft: false
prerelease: ${{ contains(steps.version.outputs.version, 'beta') || contains(steps.version.outputs.version, 'alpha') || contains(steps.version.outputs.version, 'rc') }}
generate_release_notes: false
files: |
sbom.spdx.json
body: |
## 🐳 Docker Images
### Pull the image:
```bash
# Latest version
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
# Specific version
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
# Major version (will update with patches)
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v$(echo ${{ steps.version.outputs.version_number }} | cut -d. -f1)
```
### Run the container:
```bash
# Using docker-compose (recommended)
docker-compose up -d
# Or using docker run
docker run -d \
--name sensor-log-generator \
-v $(pwd)/data:/app/data \
-v $(pwd)/config:/app/config \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
```
### Run with WAL mode disabled (for Docker Desktop on Mac/Windows):
```bash
docker run -d \
--name sensor-log-generator \
-v $(pwd)/data:/app/data \
-e SENSOR_WAL=false \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
```
---
${{ steps.changelog.outputs.CHANGELOG }}
---
## 📦 Assets
- **SBOM**: Software Bill of Materials attached below
- **Container Signature**: Images are signed with Cosign/Sigstore
## 🔗 Quick Links
- [Documentation](https://github.com/${{ github.repository }}/blob/main/README.md)
- [Container Registry](https://github.com/${{ github.repository }}/pkgs/container/${{ github.event.repository.name }})
- [Report Issues](https://github.com/${{ github.repository }}/issues)