From 5ba522d2baffa9194e58e5ebc70f204729c23a09 Mon Sep 17 00:00:00 2001 From: XFY9326 Date: Fri, 23 Feb 2024 16:29:59 +0800 Subject: [PATCH] Update --- .github/workflows/release.yml | 41 +++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 2 +- pyproject.toml | 6 ++--- 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..20cdbcc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: Release + +on: + push: + tags: + - '*' + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + environment: release + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel setuptools + pip install pytest hatch versioningit + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Build dist + run: | + hatch build + - name: Test with pytest + run: | + pytest ./tests/ + - name: Upload release + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: softprops/action-gh-release@v1 + with: + files: dist/* + - name: Publish package + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c948703..98b13a5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,4 +52,4 @@ jobs: uses: codecov/codecov-action@v4.0.1 with: token: ${{ secrets.CODECOV_TOKEN }} - slug: XFY9326/PyNdef \ No newline at end of file + slug: XFY9326/PyNdef diff --git a/pyproject.toml b/pyproject.toml index 025848b..7737491 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["hatchling"] +requires = ["hatchling", "versioningit"] build-backend = "hatchling.build" [project] name = "pyndef" -version = "1.0.0" +dynamic = ["version"] requires-python = ">=3.6" authors = [ { name = "XFY9326" } @@ -36,4 +36,4 @@ pythonpath = "src" exclude = [".github/"] [tool.hatch.version] -path = "src/pyndef/__about__.py" +source = "versioningit"