Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ jobs:
uses: ./.github/workflows/publish.yml
with:
version: ${{ fromJson(needs.zerv-versioning.outputs.versions).pep440 }}
index: "pypi"
python_version: "3.14"
secrets:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

Expand All @@ -70,6 +72,7 @@ jobs:
uses: ./.github/workflows/publish.yml
with:
version: ${{ fromJson(needs.zerv-versioning.outputs.versions).pep440 }}
repository_url: https://test.pypi.org/legacy/
index: "testpypi"
python_version: "3.14"
secrets:
PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
uses: ./.github/workflows/publish.yml
with:
version: ${{ fromJson(needs.zerv-versioning.outputs.versions).pep440 }}
repository_url: https://test.pypi.org/legacy/
index: "testpypi"
python_version: "3.14"
secrets:
PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ jobs:
with:
version: "latest"
enable-cache: true
python-version: ${{ matrix.python-version }}
python-version: ${{ inputs.python_version }}

- name: cache-uv
uses: actions/cache@8b402f58fbc84540c8b491a91e594a4576fec3d7 # v5.0.2
with:
path: |
~/.local
${{ github.workspace }}/.venv
key: uv-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}-${{ github.run_id }}
key: uv-${{ runner.os }}-py${{ inputs.python_version }}-${{ hashFiles('uv.lock') }}-${{ github.run_id }}
restore-keys: |
uv-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('uv.lock') }}-
uv-${{ runner.os }}-py${{ matrix.python-version }}-
uv-${{ runner.os }}-py${{ inputs.python_version }}-${{ hashFiles('uv.lock') }}-
uv-${{ runner.os }}-py${{ inputs.python_version }}-

- name: install-bake
run: |
Expand Down
46 changes: 22 additions & 24 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ on:
required: true
type: string
description: "PEP440 version string"
repository_url:
index:
required: false
type: string
description: "PyPI repository URL (default: official PyPI)"
default: ""
description: "Publish index (pypi or testpypi)"
default: "testpypi"
python_version:
required: false
type: string
description: "Python version"
secrets:
PYPI_API_TOKEN:
required: true
Expand All @@ -21,31 +25,25 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
- name: checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Update version in pyproject.toml
run: |
sed -i.bak 's/^version = .*/version = "${{ inputs.version }}"/' pyproject.toml
grep '^version' pyproject.toml

- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.14"

- name: Install uv
- name: setup-uv
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b # v7.2.0
with:
python-version: ${{ inputs.python_version }}
version: "latest"
enable-cache: true

- name: Build package
run: uv build
- name: install-bake
run: |
uv tool install "bakefile[lib]"
uv tool upgrade --all
bake --version

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
repository-url: ${{ inputs.repository_url || '' }}
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
skip-existing: true
- name: publish
run: |
BAKE_PUBLISH_TOKEN=${{ secrets.PYPI_API_TOKEN }} \
bake publish \
--index "${{ inputs.index }}" \
--version "${{ inputs.version }}"
10 changes: 2 additions & 8 deletions bakefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import typer
from bake import Context, command, console
from bakelib import PythonSpace
from bakelib import PythonLibSpace

PROBLEM = "number_of_connected_components_in_an_undirected_graph"
problem_option = Annotated[str, typer.Option("-p", "--problem")]
force_option = Annotated[bool, typer.Option("-f", "--force")]


class MyBakebook(PythonSpace):
class MyBakebook(PythonLibSpace):
ci: bool = False

def lint(self, ctx: Context) -> None:
Expand All @@ -37,12 +37,6 @@ def problem_test(self, ctx: Context, problem: problem_option = PROBLEM):
tests_path = str(problem_path / "test_solution.py")
self._test(ctx, tests_paths=tests_path, verbose=True, coverage_report=False)

@command("p-lint", help="Run linter")
def problem_lint(self, ctx: Context, problem: problem_option = PROBLEM):
# TODO: only for backward compat with current docs. prefer using `bake lint` instead.
_ = problem
self.lint(ctx)

@command("p-gen", help="Generate specific problem")
def problem_gen(
self, ctx: Context, problem: problem_option = PROBLEM, force: force_option = False
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ exclude = [
module-name = ["leetcode_py"]
module-root = "src"

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

# # Debug with bakefile from test pypi
# =============================================
# # Debug
Expand All @@ -136,12 +142,6 @@ module-root = "src"
# prerelease = "allow"
#
# # Debug
# [[tool.uv.index]]
# name = "testpypi"
# url = "https://test.pypi.org/simple/"
# explicit = true
#
# # Debug
# [tool.uv.sources]
# bakefile = {index = "testpypi"}
# =============================================
Expand Down
Loading