Skip to content

Commit df26305

Browse files
chore: refactor release workflows
1 parent 76c839f commit df26305

File tree

2 files changed

+170
-146
lines changed

2 files changed

+170
-146
lines changed

.github/workflows/release-agent.yml

Lines changed: 85 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,13 @@ on:
66
- 'agent-*.*.*'
77

88
jobs:
9-
create-release:
10-
name: Create GitHub Release for Agent
9+
extract-version:
10+
name: Extract version from tag
1111
runs-on: ubuntu-latest
12-
permissions:
13-
contents: write
1412
outputs:
15-
upload_url: ${{ steps.create_release.outputs.upload_url }}
1613
version: ${{ steps.version.outputs.version }}
1714

1815
steps:
19-
- name: Checkout code
20-
uses: actions/checkout@v4
21-
2216
- name: Extract version from tag
2317
id: version
2418
run: |
@@ -29,58 +23,6 @@ jobs:
2923
echo "version=$VERSION" >> $GITHUB_OUTPUT
3024
echo "Extracted version: $VERSION"
3125
32-
- name: Create Release
33-
id: create_release
34-
uses: softprops/action-gh-release@v1
35-
with:
36-
name: NetDriver Agent ${{ steps.version.outputs.version }}
37-
draft: false
38-
prerelease: false
39-
generate_release_notes: true
40-
body: |
41-
## netdriver-agent ${{ steps.version.outputs.version }}
42-
43-
### 📦 Package
44-
45-
**netdriver-agent** - FastAPI-based REST API service for network device automation
46-
47-
### 🛠️ Preparation
48-
49-
```bash
50-
# Create directories
51-
mkdir -p config/agent logs
52-
53-
# Download default configuration
54-
curl -o config/agent/agent.yml https://raw.githubusercontent.com/${{ github.repository }}/master/config/agent/agent.yml
55-
```
56-
57-
### 📥 Installation
58-
59-
**PyPI:**
60-
```bash
61-
pip install netdriver-agent==${{ steps.version.outputs.version }}
62-
```
63-
64-
**Docker:**
65-
```bash
66-
# Pull the image
67-
docker pull ghcr.io/opensecflow/netdriver-agent:${{ steps.version.outputs.version }}
68-
69-
# Run the agent
70-
docker run -d -p 8000:8000 \
71-
-v $(pwd)/config:/app/config \
72-
-v $(pwd)/logs:/app/logs \
73-
ghcr.io/opensecflow/netdriver-agent:${{ steps.version.outputs.version }}
74-
```
75-
76-
**Available tags:** `${{ steps.version.outputs.version }}`, `latest`
77-
78-
**Platforms:** `linux/amd64`, `linux/arm64`
79-
80-
### 📝 Changes
81-
82-
See [CHANGELOG](https://github.com/OpenSecFlow/netdriver/blob/master/CHANGELOG.md) for detailed changes.
83-
8426
test:
8527
name: Run tests
8628
runs-on: ubuntu-latest
@@ -115,7 +57,7 @@ jobs:
11557
11658
build-and-publish:
11759
name: Build and Publish Agent to PyPI
118-
needs: [create-release, test]
60+
needs: [extract-version, test]
11961
runs-on: ubuntu-latest
12062
container:
12163
image: ghcr.io/opensecflow/netdriver/python-poetry
@@ -138,7 +80,7 @@ jobs:
13880

13981
- name: Update agent version
14082
run: |
141-
VERSION=${{ needs.create-release.outputs.version }}
83+
VERSION=${{ needs.extract-version.outputs.version }}
14284
echo "Updating netdriver-agent version to $VERSION"
14385
poetry version $VERSION -C projects/agent
14486
@@ -160,15 +102,16 @@ jobs:
160102
echo "Publishing netdriver-agent to PyPI..."
161103
poetry publish -C projects/agent --skip-existing
162104
163-
- name: Upload wheel to release
164-
uses: softprops/action-gh-release@v1
105+
- name: Upload wheel artifact
106+
uses: actions/upload-artifact@v4
165107
with:
166-
tag_name: agent-${{ needs.create-release.outputs.version }}
167-
files: projects/agent/dist/*.whl
108+
name: agent-wheel
109+
path: projects/agent/dist/*.whl
110+
retention-days: 1
168111

169112
build-docker-image:
170113
name: Build and Push Agent Docker Image
171-
needs: [create-release, test]
114+
needs: [extract-version, test]
172115
runs-on: ubuntu-latest
173116
permissions:
174117
contents: read
@@ -194,9 +137,9 @@ jobs:
194137
with:
195138
images: ghcr.io/${{ github.repository }}/netdriver-agent
196139
tags: |
197-
type=semver,pattern={{version}},value=${{ needs.create-release.outputs.version }}
198-
type=semver,pattern={{major}}.{{minor}},value=${{ needs.create-release.outputs.version }}
199-
type=semver,pattern={{major}},value=${{ needs.create-release.outputs.version }}
140+
type=semver,pattern={{version}},value=${{ needs.extract-version.outputs.version }}
141+
type=semver,pattern={{major}}.{{minor}},value=${{ needs.extract-version.outputs.version }}
142+
type=semver,pattern={{major}},value=${{ needs.extract-version.outputs.version }}
200143
type=raw,value=latest
201144
202145
- name: Build and push Docker image
@@ -211,9 +154,78 @@ jobs:
211154
cache-to: type=gha,mode=max
212155
platforms: linux/amd64,linux/arm64
213156

157+
create-release:
158+
name: Create GitHub Release with Assets
159+
needs: [extract-version, build-and-publish, build-docker-image]
160+
runs-on: ubuntu-latest
161+
permissions:
162+
contents: write
163+
164+
steps:
165+
- name: Checkout code
166+
uses: actions/checkout@v4
167+
168+
- name: Download wheel artifact
169+
uses: actions/download-artifact@v4
170+
with:
171+
name: agent-wheel
172+
path: ./dist
173+
174+
- name: Create Release
175+
uses: softprops/action-gh-release@v1
176+
with:
177+
name: NetDriver Agent ${{ needs.extract-version.outputs.version }}
178+
draft: false
179+
prerelease: false
180+
generate_release_notes: true
181+
files: ./dist/*.whl
182+
body: |
183+
## netdriver-agent ${{ needs.extract-version.outputs.version }}
184+
185+
### 📦 Package
186+
187+
**netdriver-agent** - FastAPI-based REST API service for network device automation
188+
189+
### 🛠️ Preparation
190+
191+
```bash
192+
# Create directories
193+
mkdir -p config/agent logs
194+
195+
# Download default configuration
196+
curl -o config/agent/agent.yml https://raw.githubusercontent.com/${{ github.repository }}/master/config/agent/agent.yml
197+
```
198+
199+
### 📥 Installation
200+
201+
**PyPI:**
202+
```bash
203+
pip install netdriver-agent==${{ needs.extract-version.outputs.version }}
204+
```
205+
206+
**Docker:**
207+
```bash
208+
# Pull the image
209+
docker pull ghcr.io/opensecflow/netdriver-agent:${{ needs.extract-version.outputs.version }}
210+
211+
# Run the agent
212+
docker run -d -p 8000:8000 \
213+
-v $(pwd)/config:/app/config \
214+
-v $(pwd)/logs:/app/logs \
215+
ghcr.io/opensecflow/netdriver-agent:${{ needs.extract-version.outputs.version }}
216+
```
217+
218+
**Available tags:** `${{ needs.extract-version.outputs.version }}`, `latest`
219+
220+
**Platforms:** `linux/amd64`, `linux/arm64`
221+
222+
### 📝 Changes
223+
224+
See [CHANGELOG](https://github.com/OpenSecFlow/netdriver/blob/master/CHANGELOG.md) for detailed changes.
225+
214226
verify:
215227
name: Verify publication
216-
needs: [build-and-publish, build-docker-image, create-release]
228+
needs: [extract-version, build-and-publish, build-docker-image, create-release]
217229
runs-on: ubuntu-latest
218230

219231
steps:
@@ -228,11 +240,11 @@ jobs:
228240
- name: Verify Docker image
229241
run: |
230242
echo "Docker image published:"
231-
echo "- ghcr.io/${{ github.repository }}/netdriver-agent:${{ needs.create-release.outputs.version }}"
243+
echo "- ghcr.io/${{ github.repository }}/netdriver-agent:${{ needs.extract-version.outputs.version }}"
232244
233245
- name: Generate summary
234246
run: |
235-
VERSION=${{ needs.create-release.outputs.version }}
247+
VERSION=${{ needs.extract-version.outputs.version }}
236248
echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
237249
echo "" >> $GITHUB_STEP_SUMMARY
238250
echo "✅ Agent release created successfully" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)