Skip to content

Commit d3ba78b

Browse files
committed
feat: Add PyPI packaging and GitHub Actions auto-publish
- Configure pyproject.toml for PyPI publishing - Add GitHub Actions workflow for automatic publishing - Update project metadata and repository links - Support automatic build and publish to PyPI on release
1 parent ec2f402 commit d3ba78b

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.github/workflows/publish.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
id-token: write # 用于PyPI的trusted publishing
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.12'
22+
23+
- name: Install Poetry
24+
uses: snok/install-poetry@v1
25+
with:
26+
version: latest
27+
virtualenvs-create: true
28+
virtualenvs-in-project: true
29+
30+
- name: Load cached venv
31+
id: cached-poetry-dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: .venv
35+
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
36+
37+
- name: Install dependencies
38+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
39+
run: poetry install --no-dev --no-interaction --no-ansi
40+
41+
- name: Build package
42+
run: poetry build
43+
44+
- name: Publish to PyPI
45+
uses: pypa/gh-action-pypi-publish@release/v1
46+
with:
47+
packages-dir: dist/

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ description = "The driver for network devices, which interact with network devic
55
66
readme = "README.md"
77
license = "Apache-2.0"
8+
homepage = "https://github.com/OpenSecFlow/netdriver"
9+
repository = "https://github.com/OpenSecFlow/netdriver"
10+
documentation = "https://github.com/OpenSecFlow/netdriver#readme"
11+
keywords = ["network", "automation", "cli", "ssh", "device", "driver"]
12+
classifiers = [
13+
"Development Status :: 4 - Beta",
14+
"Intended Audience :: Developers",
15+
"Intended Audience :: System Administrators",
16+
"License :: OSI Approved :: Apache Software License",
17+
"Operating System :: OS Independent",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3.12",
20+
"Topic :: System :: Networking",
21+
"Topic :: Software Development :: Libraries :: Python Modules",
22+
]
823
packages = [
924
{include = "netdriver/agent", from = "./bases"},
1025
{include = "netdriver/simunet", from = "./bases"},

0 commit comments

Comments
 (0)