Skip to content

Commit 88d369d

Browse files
committed
add workflows
1 parent 6c61cb8 commit 88d369d

File tree

7 files changed

+131
-0
lines changed

7 files changed

+131
-0
lines changed

.github/workflows/publish_pypi.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish to PyPI via Trusted Publisher
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Update Version"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
11+
publish:
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
id-token: write
16+
contents: read
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Python
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: "3.9"
28+
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install --upgrade setuptools wheel build
33+
34+
- name: Build the package
35+
run: |
36+
python setup.py sdist # 暂不加bdist_wheel,先使用源码编译,后续会改进
37+
38+
- name: Pypi Publish
39+
uses: pypa/gh-action-pypi-publish@release/v1
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish to TestPyPI
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Update Version"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: "3.9"
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install --upgrade setuptools wheel build twine
31+
32+
- name: Build the package
33+
run: |
34+
python setup.py sdist
35+
36+
- name: Publish to TestPyPI
37+
env:
38+
TWINE_USERNAME: __token__
39+
TWINE_PASSWORD: ${{ secrets.TESTPYPI_API_TOKEN }}
40+
run: |
41+
python -m twine upload --repository testpypi dist/*

.github/workflows/update_version.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Update Version
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
update-version:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Switch to main branch
22+
run: |
23+
git checkout main
24+
25+
- name: Update _version.py
26+
run: |
27+
TAG_NAME=$(echo ${{ github.ref_name }})
28+
echo "__version__ = '${TAG_NAME:1}'" > pyfmm_gui/_version.py
29+
30+
- name: Commit changes
31+
run: |
32+
git config user.name "github-actions[bot]"
33+
git config user.email "github-actions[bot]@users.noreply.github.com"
34+
git add pyfmm_gui/_version.py
35+
git commit -m "Update version to ${{ github.ref_name }}"
36+
git push origin main # 推送到 "main" 分支
37+
38+

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/__pycache__
22
/build
3+
/dist
34
/*.egg-info
45
/pyfmm_gui/__pycache__

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include pyfmm_gui/*

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<p align="center">
66
<img alt="GitHub code size in bytes" src="https://img.shields.io/github/languages/code-size/Dengda98/PyFMM-GUI">
77
<img alt="GitHub License" src="https://img.shields.io/github/license/Dengda98/PyFMM-GUI">
8+
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/Dengda98/PyFMM-GUI/update_version.yml?label=update%20version">
9+
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/Dengda98/PyFMM-GUI/publish_pypi.yml?label=pypi%20publish">
810
</p>
911

1012
基于PyQt5开发的简易图形界面,用于计算任意速度场下的二维全局走时场。计算模块基于[***PyFMM***](https://github.com/Dengda98/PyFMM)

setup.py

+9
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,28 @@ def read_version():
88
exec(f.read())
99
return locals()['__version__']
1010

11+
def read_readme():
12+
with open("README.md", encoding="utf-8") as f:
13+
return f.read()
14+
1115
setup(
1216
name='pyfmm_gui',
1317
version=read_version(),
1418
description='A simple GUI of PyFMM',
1519
author='Zhu Dengda',
1620
author_email='[email protected]',
21+
long_description=read_readme(),
22+
long_description_content_type="text/markdown",
23+
url="https://github.com/Dengda98/PyFMM-GUI",
24+
1725
packages=find_packages(),
1826
package_data={'pyfmm_gui': ['main.ui']},
1927
include_package_data=True,
2028
python_requires='>=3.9',
2129
entry_points={
2230
'console_scripts': [
2331
'pyfmm_gui=pyfmm_gui.main:main',
32+
'pyfmm-gui=pyfmm_gui.main:main',
2433
],
2534
},
2635
)

0 commit comments

Comments
 (0)