Skip to content

Commit

Permalink
更新项目
Browse files Browse the repository at this point in the history
  • Loading branch information
lemisky committed Apr 27, 2023
1 parent 09cd922 commit f366a27
Show file tree
Hide file tree
Showing 19 changed files with 124 additions and 104 deletions.
52 changes: 31 additions & 21 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,47 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package
name: Upload Python Package & Release

on:
release:
types: [published]
push:
tags:
- "v*.*.*"

permissions:
contents: write

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
python .github/workflows/update_version.py
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U build setuptools wheel
- name: Build package
run: |
python .github/workflows/update-version.py
python -m build -n
- name: Release assets
uses: softprops/action-gh-release@v1
with:
files: dist/*
#- name: pypi-publish
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
38 changes: 0 additions & 38 deletions .github/workflows/python-test.yml.disable

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
name: Star Notify
name: Started Notify
on:
watch:
types: [started]
types: [ started ]
jobs:
Notify:
runs-on: ubuntu-latest
steps:
- name: Install Dependencies
run: |
pip install yagmail[all] requests
- name: Download Scripts
run: |
wget https://raw.githubusercontent.com/foyoux/started-notify/main/.github/workflows/started_notify.py#${{github.run_id}}
- name: Send Email
- name: Send Notify Email
run: |
python started_notify.py ${{github.token}} ${{secrets.NOTIFY_EMAIL}}
22 changes: 22 additions & 0 deletions .github/workflows/update-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os
import re
from pathlib import Path


def main():
tag = os.getenv('GITHUB_REF_NAME')
if not tag:
raise RuntimeError('tag not exists')
if not tag.startswith('v'):
raise ValueError(f'tag({tag}) not starts with "v"')
print(f'tag: {tag}')
init = Path('src/pygtrans/__init__.py')
init.write_text(re.sub(
r'^__version__ = [\'"]\d+\.\d+\.\d+[\'"]$',
f"__version__ = '{tag[1:]}'",
init.read_text(encoding='utf8'), flags=re.M
), encoding='utf8')


if __name__ == '__main__':
main()
9 changes: 0 additions & 9 deletions .github/workflows/update_api_key.py.disable

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/update_version.py

This file was deleted.

1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
graft src/pygtrans/templates
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

```bash
pip install -U pygtrans
pip install git+ssh://git@github.com/foyoux/pygtrans.git
pip install git+https://github.com/foyoux/pygtrans.git
```


Expand Down
49 changes: 45 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,48 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"


[project]
name = "pygtrans"
authors = [
{ name = "foyoux" },
]
description = "python package pygtrans"
keywords = ["pygtrans"]
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dynamic = ["version", "dependencies"]


[project.urls]
"Source" = "https://github.com/foyoux/pygtrans"
"Homepage" = "https://github.com/foyoux/pygtrans"
"Bug Tracker" = "https://github.com/foyoux/pygtrans/issues"


[project.scripts]
pygtrans = "pygtrans:main"


[tool.setuptools]
include-package-data = true


[tool.setuptools.dynamic]
version = { attr = "pygtrans.__version__" }
dependencies = { file = "requirements.txt" }


[tool.setuptools.packages.find]
where = ["src"]
exclude = ["tests*"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pygtrans/__init__.py → src/pygtrans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
__title__ = 'pygtrans'
__description__ = 'Google Translate, support APIKEY'
__url__ = 'https://github.com/foyoux/pygtrans'
__version__ = '1.2.0'
__author__ = 'foyou'
__version__ = '0.0.1'
__author__ = 'foyoux'
__author_email__ = 'yimi.0822@qq.com'
__license__ = 'GPL-3.0'
__copyright__ = f'Copyright 2021 {__author__}'
Expand Down
4 changes: 4 additions & 0 deletions src/pygtrans/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pygtrans import main

if __name__ == '__main__':
main()
Empty file added src/tests/__init__.py
Empty file.
14 changes: 14 additions & 0 deletions src/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os.path
from pathlib import Path

import pytest


@pytest.fixture
def data():
return {'pytest': 'fixture'}


@pytest.fixture
def base():
return Path(os.path.dirname(__file__))

0 comments on commit f366a27

Please sign in to comment.