From eea8011f36e7e30c5003194ae843c6169df44aa3 Mon Sep 17 00:00:00 2001 From: lv10 Date: Sat, 14 Mar 2026 03:39:14 -0400 Subject: [PATCH] fix(ci): fix semantic-release token, uv paths, pre-commit prettier, PyPI publish condition, and stale pip config --- .github/workflows/release.yml | 29 +++++++++++++++++++++++++---- .pre-commit-config.yaml | 7 ++++--- CHANGELOG.md | 0 pyproject.toml | 4 +++- 4 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a1253a..75e2a08 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,18 +18,39 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} - name: Install uv uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + + - name: Set up Python + run: uv python install + + - name: Install dependencies + run: uv sync --all-extras --dev - name: Python Semantic Release id: release - uses: python-semantic-release/python-semantic-release@v9.15.2 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --global user.name "github-actions [bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + # We run versioning and publishing manually via uv to ensure it has access to the environment + uv run semantic-release -v version + + # Check if a new version was released by looking for built dist files + if [ -d "dist" ] && [ "$(ls -A dist)" ]; then + echo "released=true" >> $GITHUB_OUTPUT + fi + + uv run semantic-release -v publish - name: Publish to PyPI if: steps.release.outputs.released == 'true' run: uv publish env: - UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} # Fallback if Trusted Publishing is not set + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0808092..a99c298 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.9.9 + rev: v0.15.6 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - id: ruff-format - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-ast - id: check-yaml @@ -21,9 +21,10 @@ repos: - id: end-of-file-fixer - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.1.0 + rev: v4.0.0-alpha.8 hooks: - id: prettier + exclude: ^CHANGELOG\.md$ - repo: local hooks: diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml index a5396c4..1eaa126 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,8 @@ dev = [ [tool.semantic_release] version_toml = ["pyproject.toml:project.version"] +version_variable = ["bestbuyapi/__init__.py:__version__"] +tag_format = "{version}" build_command = "uv build" [tool.semantic_release.branches.main] @@ -76,7 +78,7 @@ default_bump_level = 0 [tool.semantic_release.remote] name = "origin" type = "github" -token = "GH_TOKEN" +token = { env = "GH_TOKEN" } [tool.semantic_release.publish] dist_glob_patterns = ["dist/*"]