Skip to content

Commit 36736f8

Browse files
chord: update release workflows to support image.
1 parent 4158f2d commit 36736f8

File tree

7 files changed

+812
-215
lines changed

7 files changed

+812
-215
lines changed

.dockerignore

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.github
5+
6+
# Python
7+
__pycache__
8+
*.py[cod]
9+
*$py.class
10+
*.so
11+
.Python
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
projects/*/dist/
28+
29+
# Virtual environments
30+
.venv
31+
venv/
32+
ENV/
33+
env/
34+
35+
# IDE
36+
.vscode/
37+
.idea/
38+
*.swp
39+
*.swo
40+
*~
41+
.DS_Store
42+
43+
# Testing
44+
.pytest_cache/
45+
.coverage
46+
htmlcov/
47+
.tox/
48+
*.cover
49+
50+
# Logs
51+
logs/
52+
*.log
53+
54+
# Documentation
55+
docs/
56+
*.md
57+
!README.md
58+
59+
.claude/
60+

.github/workflows/README.md

Lines changed: 184 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This directory contains GitHub Actions workflows for automated building, testing
44

55
## Workflows
66

7-
### 1. Build Test (`build-test.yml`)
7+
### 1. Build (`build.yml`)
88

99
**Trigger**: Pull requests and pushes to master/main branch
1010

@@ -44,37 +44,70 @@ This directory contains GitHub Actions workflows for automated building, testing
4444
- **Projects**: `all`, `agent`, `simunet`, or `agent,simunet`
4545
4. Click "Run workflow"
4646

47-
**Note**: Requires the CI Docker image to be built first (see section 4 below)
47+
**Note**: Requires the CI Docker image to be built first (see section 5 below)
4848

49-
### 3. Release and Publish (`release.yml`)
49+
### 3. Release and Publish
5050

51-
**Trigger**: When a version tag is pushed (e.g., `v0.3.0`)
51+
The project supports independent release workflows for agent and simunet:
5252

53-
**Purpose**: Creates GitHub release and publishes to PyPI
53+
#### 3.1. Independent Agent Release (`release-agent.yml`)
54+
55+
**Trigger**: When an agent-prefixed tag is pushed (e.g., `agent-1.0.0`)
56+
57+
**Purpose**: Creates GitHub release and publishes ONLY agent package to PyPI
5458

5559
**What it does**:
5660

57-
- Creates a GitHub release from the tag
58-
- Builds both packages
61+
- Creates a GitHub release for agent
62+
- Builds only agent package
5963
- Publishes to PyPI
60-
- Attaches wheel files to the release
64+
- Builds and pushes agent Docker image to GHCR
65+
- Attaches wheel file to the release
6166

6267
**Usage**:
6368

6469
```bash
65-
# Bump version in pyproject.toml files
66-
poetry version patch # or minor, major
70+
# Update agent version in pyproject.toml (optional, will be updated by workflow)
71+
poetry version 1.0.0 -C projects/agent
6772

68-
# Commit version changes
69-
git add projects/*/pyproject.toml
70-
git commit -m "chore: bump version to 0.3.1"
73+
# Commit version changes (optional)
74+
git add projects/agent/pyproject.toml
75+
git commit -m "chore: bump agent version to 1.0.0"
7176

72-
# Create and push tag (without 'v' prefix)
73-
git tag 0.3.1
77+
# Create and push agent tag
78+
git tag agent-1.0.0
7479
git push origin master
75-
git push origin 0.3.1
80+
git push origin agent-1.0.0
81+
```
82+
83+
#### 3.2. Independent Simunet Release (`release-simunet.yml`)
84+
85+
**Trigger**: When a simunet-prefixed tag is pushed (e.g., `simunet-2.5.0`)
86+
87+
**Purpose**: Creates GitHub release and publishes ONLY simunet package to PyPI
88+
89+
**What it does**:
7690

77-
# Note: Both '0.3.1' and 'v0.3.1' formats are supported
91+
- Creates a GitHub release for simunet
92+
- Builds only simunet package
93+
- Publishes to PyPI
94+
- Builds and pushes simunet Docker image to GHCR
95+
- Attaches wheel file to the release
96+
97+
**Usage**:
98+
99+
```bash
100+
# Update simunet version in pyproject.toml (optional, will be updated by workflow)
101+
poetry version 2.5.0 -C projects/simunet
102+
103+
# Commit version changes (optional)
104+
git add projects/simunet/pyproject.toml
105+
git commit -m "chore: bump simunet version to 2.5.0"
106+
107+
# Create and push simunet tag
108+
git tag simunet-2.5.0
109+
git push origin master
110+
git push origin simunet-2.5.0
78111
```
79112

80113
## Setup Requirements
@@ -114,52 +147,80 @@ Add the following secrets to your GitHub repository:
114147
GitHub Actions supports PyPI's trusted publishing (no token needed):
115148

116149
1. Go to PyPI → Your account → Publishing
117-
2. Add publisher:
150+
2. Add publisher for each package:
118151
- **Owner**: Your GitHub username/organization
119152
- **Repository**: `netdriver`
120-
- **Workflow**: `release.yml`
153+
- **Workflow**: `release-agent.yml` (for netdriver-agent)
154+
- **Workflow**: `release-simunet.yml` (for netdriver-simunet)
121155
- **Environment**: `pypi`
122156

123-
3. Update workflow to use trusted publishing (already configured with `id-token: write`)
157+
3. Both workflows are already configured with `id-token: write` for trusted publishing
124158

125159
## Release Process
126160

127-
### Standard Release
161+
### Agent Release
128162

129-
1. **Update version numbers**:
163+
Use this when you only need to release the agent:
164+
165+
1. **Update version number** (optional):
166+
167+
```bash
168+
poetry version 1.0.0 -C projects/agent
169+
```
170+
171+
2. **Commit changes** (optional):
172+
173+
```bash
174+
git add projects/agent/pyproject.toml
175+
git commit -m "chore: bump agent version to 1.0.0"
176+
git push origin master
177+
```
178+
179+
3. **Create and push tag**:
130180

131181
```bash
132-
# From repository root
133-
poetry version -P projects/agent 0.3.1
134-
poetry version -P projects/simunet 0.3.1
135-
136-
# Or use Poetry's bump commands
137-
poetry version -P projects/agent patch # 0.3.0 → 0.3.1
138-
poetry version -P projects/agent minor # 0.3.0 → 0.4.0
139-
poetry version -P projects/agent major # 0.3.0 → 1.0.0
182+
git tag agent-1.0.0
183+
git push origin agent-1.0.0
140184
```
141185

142-
2. **Update CHANGELOG.md** (if exists)
186+
4. **Workflow will automatically**:
187+
- Update agent version to 1.0.0
188+
- Create GitHub release for agent
189+
- Build agent package
190+
- Publish to PyPI
191+
- Build and push agent Docker image to GHCR
192+
193+
### Simunet Release
143194

144-
3. **Commit changes**:
195+
Use this when you need to release simunet:
196+
197+
1. **Update version number** (optional):
145198

146199
```bash
147-
git add projects/*/pyproject.toml
148-
git commit -m "chore: bump version to 0.3.1"
200+
poetry version 2.5.0 -C projects/simunet
201+
```
202+
203+
2. **Commit changes** (optional):
204+
205+
```bash
206+
git add projects/simunet/pyproject.toml
207+
git commit -m "chore: bump simunet version to 2.5.0"
149208
git push origin master
150209
```
151210

152-
4. **Create and push tag**:
211+
3. **Create and push tag**:
153212

154213
```bash
155-
git tag 0.3.1
156-
git push origin 0.3.1
214+
git tag simunet-2.5.0
215+
git push origin simunet-2.5.0
157216
```
158217

159-
5. **Workflow will automatically**:
160-
- Create GitHub release
161-
- Build packages
218+
4. **Workflow will automatically**:
219+
- Update simunet version to 2.5.0
220+
- Create GitHub release for simunet
221+
- Build simunet package
162222
- Publish to PyPI
223+
- Build and push simunet Docker image to GHCR
163224

164225
### Test Release
165226

@@ -215,9 +276,87 @@ Check that:
215276
- Check package name is correct (use underscore vs hyphen)
216277
- Verify on PyPI website first
217278

279+
## Docker Image Publishing
280+
281+
All release workflows automatically build and publish Docker images to GitHub Container Registry (GHCR).
282+
283+
### Docker Image Tags
284+
285+
Each release creates multiple tags for flexibility:
286+
287+
- `latest` - Always points to the most recent release
288+
- `<version>` - Specific version (e.g., `1.0.0`)
289+
- `<major>.<minor>` - Minor version (e.g., `1.0`)
290+
- `<major>` - Major version (e.g., `1`)
291+
292+
### Multi-Architecture Support
293+
294+
Docker images are built for multiple architectures:
295+
296+
- `linux/amd64` (x86_64)
297+
- `linux/arm64` (ARM64/Apple Silicon)
298+
299+
### Image Locations
300+
301+
| Package | Registry | Image Name |
302+
|---------|----------|------------|
303+
| Agent | GHCR | `ghcr.io/opensecflow/netdriver/netdriver-agent` |
304+
| Simunet | GHCR | `ghcr.io/opensecflow/netdriver/netdriver-simunet` |
305+
306+
### Using Docker Images
307+
308+
**Agent:**
309+
```bash
310+
# Pull latest
311+
docker pull ghcr.io/opensecflow/netdriver/netdriver-agent:latest
312+
313+
# Pull specific version
314+
docker pull ghcr.io/opensecflow/netdriver/netdriver-agent:1.0.0
315+
316+
# Run agent
317+
docker run -d -p 8000:8000 \
318+
-v $(pwd)/config:/app/config \
319+
-v $(pwd)/logs:/app/logs \
320+
ghcr.io/opensecflow/netdriver/netdriver-agent:latest
321+
```
322+
323+
**Simunet:**
324+
```bash
325+
# Pull latest
326+
docker pull ghcr.io/opensecflow/netdriver/netdriver-simunet:latest
327+
328+
# Pull specific version
329+
docker pull ghcr.io/opensecflow/netdriver/netdriver-simunet:2.5.0
330+
331+
# Run simunet with host network mode (SSH ports bind directly to host)
332+
docker run -d --network host \
333+
-v $(pwd)/config:/app/config \
334+
-v $(pwd)/logs:/app/logs \
335+
ghcr.io/opensecflow/netdriver/netdriver-simunet:latest
336+
```
337+
338+
**Note**: Simunet uses host network mode (`--network host`) to bind SSH ports (default 2201-2220) directly to the host. This is required for proper SSH server functionality.
339+
340+
### Docker Image Authentication
341+
342+
Docker images are public and can be pulled without authentication. For private repositories, authenticate first:
343+
344+
```bash
345+
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
346+
```
347+
348+
## Tag Naming Convention
349+
350+
The project uses prefixed tag patterns for independent releases:
351+
352+
| Tag Pattern | Workflow | Releases | Artifacts |
353+
|------------|----------|----------|-----------|
354+
| `agent-1.0.0` | `release-agent.yml` | Agent only | PyPI package + Docker image |
355+
| `simunet-2.5.0` | `release-simunet.yml` | Simunet only | PyPI package + Docker image |
356+
218357
## Using Pre-built Docker Images
219358

220-
### 4. Build CI Image (`build-ci-image.yml`)
359+
### 5. Build CI Image (`build-ci-image.yml`)
221360

222361
**Purpose**: Creates a Docker image with Poetry and Python pre-installed for faster CI/CD
223362

@@ -280,9 +419,10 @@ netdriver/
280419
│ ├── Dockerfile.ci # CI/CD Docker image
281420
│ └── workflows/
282421
│ ├── build-ci-image.yml # Build Docker image
283-
│ ├── build-test.yml # PR/push build validation
284-
│ ├── publish-pypi.yml # Docker-based publishing
285-
│ └── release.yml # Tag-based release
422+
│ ├── build.yml # PR/push build validation
423+
│ ├── publish-pypi.yml # Manual PyPI publishing
424+
│ ├── release-agent.yml # Agent release workflow
425+
│ └── release-simunet.yml # Simunet release workflow
286426
├── bases/
287427
│ └── netdriver/
288428
│ ├── agent/ # REST API service

0 commit comments

Comments
 (0)