From 2513bc360d8d3d5381719ddad620f0ef9e01a1a2 Mon Sep 17 00:00:00 2001 From: Martin Reurekas Date: Sun, 13 Sep 2026 22:58:47 +0200 Subject: [PATCH] added gitea workflow and fixed some issues in pyproject.toml --- .gitea/workflows/build.yaml | 27 ++++++++++++ .gitea/workflows/bump_version.yaml | 69 ++++++++++++++++++++++++++++++ pyproject.toml | 5 ++- 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 .gitea/workflows/build.yaml create mode 100644 .gitea/workflows/bump_version.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..3189b99 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,27 @@ +name: Build and Publish + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Build package + run: uv build + + - name: Publish to Gitea package registry + run: | + uv publish \ + --publish-url https://gitea.semrks.nl:8418/api/packages/mreurekas/pypi \ + --username ${{ secrets.CI_USER }} \ + --password ${{ secrets.CI_TOKEN }} + env: + UV_PUBLISH_TOKEN: ${{ secrets.CI_TOKEN }} diff --git a/.gitea/workflows/bump_version.yaml b/.gitea/workflows/bump_version.yaml new file mode 100644 index 0000000..454cd18 --- /dev/null +++ b/.gitea/workflows/bump_version.yaml @@ -0,0 +1,69 @@ +# .gitea/workflows/bump-version.yaml +name: Bump Version + +on: + workflow_dispatch: + inputs: + bump: + description: 'Version part to bump' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major + +jobs: + bump: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITEA_TOKEN }} + + - name: Configure git + run: | + git config user.name "gitea-actions" + git config user.email "actions@semrks.nl" + + - name: Bump version in pyproject.toml + id: bump + run: | + python3 - <<'EOF' + import re + + bump = "${{ inputs.bump }}" + path = "pyproject.toml" + + with open(path) as f: + content = f.read() + + match = re.search(r'(?m)^version = "(\d+)\.(\d+)\.(\d+)"$', content) + major, minor, patch = map(int, match.groups()) + + if bump == "major": + major, minor, patch = major + 1, 0, 0 + elif bump == "minor": + minor, patch = minor + 1, 0 + else: + patch += 1 + + new_version = f"{major}.{minor}.{patch}" + new_content = content[:match.start()] + f'version = "{new_version}"' + content[match.end():] + + with open(path, "w") as f: + f.write(new_content) + + with open("$GITEA_ENV", "a") as f: + f.write(f"NEW_VERSION={new_version}\n") + EOF + + - name: Commit and tag + run: | + git add pyproject.toml + git commit -m "Bump version to ${NEW_VERSION}" + git tag "v${NEW_VERSION}" + git push origin HEAD:${{ github.ref_name }} + git push origin "v${NEW_VERSION}" diff --git a/pyproject.toml b/pyproject.toml index 372dc2c..2ccae31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,8 @@ description = "CPU Governor Auto Adjust based on Roon Activity and System Load" authors = [ { name = "Martin Reurekas", email = "martin@semrks.nl" } ] -license = { file = "LICENSE" } +license = "MIT" +license-files = ["LICENSE"] readme = "README.md" requires-python = ">=3.12" dependencies = [ @@ -23,7 +24,7 @@ dev = [ ] [tool.setuptools.packages.find] -where = [".", "cpu_governor_auto_adjust"] +where = ["."] [project.scripts] cpu_governor_auto_adjust = "cpu_governor_auto_adjust.cpu_governor_auto_adjust:main"