From dd9737c72550824fc6ffde4f79ff759c0d0c5b96 Mon Sep 17 00:00:00 2001 From: zhaomaoniu <2667292003@qq.com> Date: Sun, 14 Apr 2024 16:14:01 +0800 Subject: [PATCH] feat: add github action --- .github/actions/setup-python/action.yml | 21 ++++++++++++++ .github/workflows/release.yml | 37 +++++++++++++++++++++++++ bestdori/render/__init__.py | 2 +- pyproject.toml | 2 ++ 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 .github/actions/setup-python/action.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/actions/setup-python/action.yml b/.github/actions/setup-python/action.yml new file mode 100644 index 0000000..ce7d0ff --- /dev/null +++ b/.github/actions/setup-python/action.yml @@ -0,0 +1,21 @@ +name: Setup Python +description: Setup Python + +inputs: + python-version: + description: Python version + required: false + default: "3.10" + +runs: + using: "composite" + steps: + - uses: pdm-project/setup-pdm@v3 + name: Setup PDM + with: + python-version: ${{ inputs.python-version }} + architecture: "x64" + cache: true + + - run: pdm sync -G:all + shell: bash \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..65ac8c9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Release + +on: + push: + tags: + - v* + +jobs: + pypi-publish: + name: upload release to PyPI + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + steps: + - uses: actions/checkout@v3 + + - name: Setup Python environment + uses: ./.github/actions/setup-python + + - name: Get Version + id: version + run: | + echo "VERSION=$(pdm show --version)" >> $GITHUB_OUTPUT + echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Check Version + if: steps.version.outputs.VERSION != steps.version.outputs.TAG_VERSION + run: exit 1 + + - name: Publish Package + run: | + pdm publish + gh release upload --clobber ${{ steps.version.outputs.TAG_NAME }} dist/*.tar.gz dist/*.whl + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/bestdori/render/__init__.py b/bestdori/render/__init__.py index b97340e..b1ccf5f 100644 --- a/bestdori/render/__init__.py +++ b/bestdori/render/__init__.py @@ -49,4 +49,4 @@ def render(chart: Chart, config: Config = get_config()) -> Image.Image: return utils.paste(bg, result, (0, 0)) -__all__ = ["render", "config"] +__all__ = ["render"] diff --git a/pyproject.toml b/pyproject.toml index e83b149..ae3a4f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,8 @@ license = {text = "MIT"} requires = ["pdm-backend"] build-backend = "pdm.backend" +[tool.pdm.build] +includes = ["bestdori"] [tool.pdm] distribution = true