Skip to content

Commit

Permalink
change build script (#677)
Browse files Browse the repository at this point in the history
* delete test

* change action

* change script
  • Loading branch information
SAKURA-CAT authored Aug 18, 2024
1 parent cbbb21e commit 27c6b71
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
with:
python-version: "3.10"

- name: Checkout Version
run: |
export VERSION=$(echo $GITHUB_REF | sed -n 's/refs\/tags\/v//p')
- name: Install Dependencies
run: |
pip install -r requirements.txt
Expand All @@ -30,14 +34,17 @@ jobs:
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

run: |
python -m build
python -m twine upload dist/*
# - run: cp dist/*.whl .
# - name: Release
# uses: softprops/action-gh-release@v1
# if: startsWith(github.ref, 'refs/tags/')
# with:
# body: ${{ github.event.head_commit.message }}
# files: |
# *.whl
python -m script/build_pypi.py
# python -m twine upload dist/*

- run: cp dist/*.whl .

- run: cat swanlab/package.json

- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
body: ${{ github.event.head_commit.message }}
files: |
*.whl
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"name": "构建项目",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/build_pypi.py",
"program": "${workspaceFolder}/script/build_pypi.py",
"console": "integratedTerminal",
"justMyCode": true,
"cwd": "${workspaceFolder}"
Expand Down
15 changes: 13 additions & 2 deletions build_pypi.py → script/build_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@
"""
import subprocess
import shutil
import json
import os

# 如果dist文件夹存在则删除
if os.path.exists("dist"):
shutil.rmtree("dist")
if os.path.exists("../dist"):
shutil.rmtree("../dist")

# 设置版本号
version = os.getenv("VERSION")
if not version:
raise ValueError("尚未指定构建版本号")
with open("../swanlab/package.json", 'r+') as f:
p = json.load(f)
p["version"] = version
json.dump(p, f, indent=4)

# 构建python项目
subprocess.run("python -m build", shell=True)
14 changes: 0 additions & 14 deletions script/test.py

This file was deleted.

2 changes: 1 addition & 1 deletion swanlab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swanlab",
"version": "0.3.16",
"version": "development",

This comment has been minimized.

Copy link
@breakds

breakds Aug 18, 2024

Not an expert in python packaging, but should this be 0.3.17?

"description": "",
"python": "true"
}

0 comments on commit 27c6b71

Please sign in to comment.