Skip to content

Commit 8769b26

Browse files
chore: refactor release workflows using draft
1 parent a44cf99 commit 8769b26

File tree

2 files changed

+200
-106
lines changed

2 files changed

+200
-106
lines changed

.github/workflows/release-agent.yml

Lines changed: 100 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,71 @@ jobs:
2323
echo "version=$VERSION" >> $GITHUB_OUTPUT
2424
echo "Extracted version: $VERSION"
2525
26+
create-draft-release:
27+
name: Create Draft Release
28+
needs: [extract-version]
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: write
32+
outputs:
33+
release_id: ${{ steps.create_release.outputs.id }}
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
39+
- name: Create Draft Release
40+
id: create_release
41+
uses: softprops/action-gh-release@v1
42+
with:
43+
name: NetDriver Agent ${{ needs.extract-version.outputs.version }}
44+
draft: true
45+
prerelease: false
46+
generate_release_notes: true
47+
body: |
48+
## netdriver-agent ${{ needs.extract-version.outputs.version }}
49+
50+
### 📦 Package
51+
52+
**netdriver-agent** - FastAPI-based REST API service for network device automation
53+
54+
### 🛠️ Preparation
55+
56+
```bash
57+
# Create directories
58+
mkdir -p config/agent logs
59+
60+
# Download default configuration
61+
curl -o config/agent/agent.yml https://raw.githubusercontent.com/${{ github.repository }}/master/config/agent/agent.yml
62+
```
63+
64+
### 📥 Installation
65+
66+
**PyPI:**
67+
```bash
68+
pip install netdriver-agent==${{ needs.extract-version.outputs.version }}
69+
```
70+
71+
**Docker:**
72+
```bash
73+
# Pull the image
74+
docker pull ghcr.io/opensecflow/netdriver-agent:${{ needs.extract-version.outputs.version }}
75+
76+
# Run the agent
77+
docker run -d -p 8000:8000 \
78+
-v $(pwd)/config:/app/config \
79+
-v $(pwd)/logs:/app/logs \
80+
ghcr.io/opensecflow/netdriver-agent:${{ needs.extract-version.outputs.version }}
81+
```
82+
83+
**Available tags:** `${{ needs.extract-version.outputs.version }}`, `latest`
84+
85+
**Platforms:** `linux/amd64`, `linux/arm64`
86+
87+
### 📝 Changes
88+
89+
See [CHANGELOG](https://github.com/OpenSecFlow/netdriver/blob/master/CHANGELOG.md) for detailed changes.
90+
2691
test:
2792
name: Run tests
2893
runs-on: ubuntu-latest
@@ -154,78 +219,60 @@ jobs:
154219
cache-to: type=gha,mode=max
155220
platforms: linux/amd64,linux/arm64
156221

157-
create-release:
158-
name: Create GitHub Release with Assets
159-
needs: [extract-version, build-and-publish, build-docker-image]
222+
upload-assets:
223+
name: Upload Assets to Release
224+
needs: [extract-version, create-draft-release, build-and-publish, build-docker-image]
160225
runs-on: ubuntu-latest
161226
permissions:
162227
contents: write
163228

164229
steps:
165-
- name: Checkout code
166-
uses: actions/checkout@v4
167-
168230
- name: Download wheel artifact
169231
uses: actions/download-artifact@v4
170232
with:
171233
name: agent-wheel
172234
path: ./dist
173235

174-
- name: Create Release
236+
- name: Upload wheel to release
175237
uses: softprops/action-gh-release@v1
176238
with:
177-
name: NetDriver Agent ${{ needs.extract-version.outputs.version }}
178-
draft: false
179-
prerelease: false
180-
generate_release_notes: true
239+
tag_name: agent-${{ needs.extract-version.outputs.version }}
181240
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
194241

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
242+
publish-release:
243+
name: Publish Release
244+
needs: [extract-version, create-draft-release, upload-assets]
245+
runs-on: ubuntu-latest
246+
permissions:
247+
contents: write
223248

224-
See [CHANGELOG](https://github.com/OpenSecFlow/netdriver/blob/master/CHANGELOG.md) for detailed changes.
249+
steps:
250+
- name: Publish Release
251+
uses: actions/github-script@v7
252+
with:
253+
script: |
254+
const tag = 'agent-${{ needs.extract-version.outputs.version }}';
255+
256+
// Get the release by tag
257+
const { data: release } = await github.rest.repos.getReleaseByTag({
258+
owner: context.repo.owner,
259+
repo: context.repo.repo,
260+
tag: tag
261+
});
262+
263+
// Update release to publish it
264+
await github.rest.repos.updateRelease({
265+
owner: context.repo.owner,
266+
repo: context.repo.repo,
267+
release_id: release.id,
268+
draft: false
269+
});
270+
271+
console.log(`Release ${tag} published successfully!`);
225272
226273
verify:
227274
name: Verify publication
228-
needs: [extract-version, build-and-publish, build-docker-image, create-release]
275+
needs: [extract-version, build-and-publish, build-docker-image, publish-release]
229276
runs-on: ubuntu-latest
230277

231278
steps:

.github/workflows/release-simunet.yml

Lines changed: 100 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,71 @@ jobs:
2323
echo "version=$VERSION" >> $GITHUB_OUTPUT
2424
echo "Extracted version: $VERSION"
2525
26+
create-draft-release:
27+
name: Create Draft Release
28+
needs: [extract-version]
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: write
32+
outputs:
33+
release_id: ${{ steps.create_release.outputs.id }}
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
39+
- name: Create Draft Release
40+
id: create_release
41+
uses: softprops/action-gh-release@v1
42+
with:
43+
name: NetDriver Simunet ${{ needs.extract-version.outputs.version }}
44+
draft: true
45+
prerelease: false
46+
generate_release_notes: true
47+
body: |
48+
## netdriver-simunet ${{ needs.extract-version.outputs.version }}
49+
50+
### 📦 Package
51+
52+
**netdriver-simunet** - SSH server simulation for testing network device terminals
53+
54+
### 🛠️ Preparation
55+
56+
```bash
57+
# Create directories
58+
mkdir -p config/simunet logs
59+
60+
# Download default configuration
61+
curl -o config/simunet/simunet.yml https://raw.githubusercontent.com/${{ github.repository }}/master/config/simunet/simunet.yml
62+
```
63+
64+
### 📥 Installation
65+
66+
**PyPI:**
67+
```bash
68+
pip install netdriver-simunet==${{ needs.extract-version.outputs.version }}
69+
```
70+
71+
**Docker:**
72+
```bash
73+
# Pull the image
74+
docker pull ghcr.io/opensecflow/netdriver-simunet:${{ needs.extract-version.outputs.version }}
75+
76+
# Run with host network mode
77+
docker run -d --network host \
78+
-v $(pwd)/config:/app/config \
79+
-v $(pwd)/logs:/app/logs \
80+
ghcr.io/opensecflow/netdriver-simunet:${{ needs.extract-version.outputs.version }}
81+
```
82+
83+
**Available tags:** `${{ needs.extract-version.outputs.version }}`, `latest`
84+
85+
**Platforms:** `linux/amd64`, `linux/arm64`
86+
87+
### 📝 Changes
88+
89+
See [CHANGELOG](https://github.com/OpenSecFlow/netdriver/blob/master/CHANGELOG.md) for detailed changes.
90+
2691
test:
2792
name: Run tests
2893
runs-on: ubuntu-latest
@@ -154,78 +219,60 @@ jobs:
154219
cache-to: type=gha,mode=max
155220
platforms: linux/amd64,linux/arm64
156221

157-
create-release:
158-
name: Create GitHub Release with Assets
159-
needs: [extract-version, build-and-publish, build-docker-image]
222+
upload-assets:
223+
name: Upload Assets to Release
224+
needs: [extract-version, create-draft-release, build-and-publish, build-docker-image]
160225
runs-on: ubuntu-latest
161226
permissions:
162227
contents: write
163228

164229
steps:
165-
- name: Checkout code
166-
uses: actions/checkout@v4
167-
168230
- name: Download wheel artifact
169231
uses: actions/download-artifact@v4
170232
with:
171233
name: simunet-wheel
172234
path: ./dist
173235

174-
- name: Create Release
236+
- name: Upload wheel to release
175237
uses: softprops/action-gh-release@v1
176238
with:
177-
name: NetDriver Simunet ${{ needs.extract-version.outputs.version }}
178-
draft: false
179-
prerelease: false
180-
generate_release_notes: true
239+
tag_name: simunet-${{ needs.extract-version.outputs.version }}
181240
files: ./dist/*.whl
182-
body: |
183-
## netdriver-simunet ${{ needs.extract-version.outputs.version }}
184-
185-
### 📦 Package
186-
187-
**netdriver-simunet** - SSH server simulation for testing network device terminals
188-
189-
### 🛠️ Preparation
190-
191-
```bash
192-
# Create directories
193-
mkdir -p config/simunet logs
194241

195-
# Download default configuration
196-
curl -o config/simunet/simunet.yml https://raw.githubusercontent.com/${{ github.repository }}/master/config/simunet/simunet.yml
197-
```
198-
199-
### 📥 Installation
200-
201-
**PyPI:**
202-
```bash
203-
pip install netdriver-simunet==${{ needs.extract-version.outputs.version }}
204-
```
205-
206-
**Docker:**
207-
```bash
208-
# Pull the image
209-
docker pull ghcr.io/opensecflow/netdriver-simunet:${{ needs.extract-version.outputs.version }}
210-
211-
# Run with host network mode
212-
docker run -d --network host \
213-
-v $(pwd)/config:/app/config \
214-
-v $(pwd)/logs:/app/logs \
215-
ghcr.io/opensecflow/netdriver-simunet:${{ 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
242+
publish-release:
243+
name: Publish Release
244+
needs: [extract-version, create-draft-release, upload-assets]
245+
runs-on: ubuntu-latest
246+
permissions:
247+
contents: write
223248

224-
See [CHANGELOG](https://github.com/OpenSecFlow/netdriver/blob/master/CHANGELOG.md) for detailed changes.
249+
steps:
250+
- name: Publish Release
251+
uses: actions/github-script@v7
252+
with:
253+
script: |
254+
const tag = 'simunet-${{ needs.extract-version.outputs.version }}';
255+
256+
// Get the release by tag
257+
const { data: release } = await github.rest.repos.getReleaseByTag({
258+
owner: context.repo.owner,
259+
repo: context.repo.repo,
260+
tag: tag
261+
});
262+
263+
// Update release to publish it
264+
await github.rest.repos.updateRelease({
265+
owner: context.repo.owner,
266+
repo: context.repo.repo,
267+
release_id: release.id,
268+
draft: false
269+
});
270+
271+
console.log(`Release ${tag} published successfully!`);
225272
226273
verify:
227274
name: Verify publication
228-
needs: [extract-version, build-and-publish, build-docker-image, create-release]
275+
needs: [extract-version, build-and-publish, build-docker-image, publish-release]
229276
runs-on: ubuntu-latest
230277

231278
steps:

0 commit comments

Comments
 (0)