diff --git a/.bumpversion.toml b/.bumpversion.toml index 18334f1..e02a3d7 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -1,28 +1,31 @@ [tool.bumpversion] current_version = "2025.04.0" -parse = "^(?P\\d{4})\\.(?P\\d{2})\\.(?P\\d+)$" -serialize = ["{year}.{month}.{patch}"] +parse = '^(?P\d{4})\.(?P\d{2})\.(?P\d+)$' +# ← use your part names here and pad month to two digits +serialize = ["{year}.{month:02d}.{patch}"] tag = true tag_name = "v{new_version}" commit = true message = "Release: {new_version}" [tool.bumpversion.parts.year] -type = "calver" -calver_format = "%Y" +type = "calver" +# calver_format only affects how the part’s default or reset value is computed, +# you can leave this or remove if you don’t need it. [tool.bumpversion.parts.month] -type = "calver" -calver_format = "%m" +type = "calver" +# likewise, calver_format here is optional once you’re formatting via Python syntax. [tool.bumpversion.parts.patch] -type = "integer" +type = "integer" [[tool.bumpversion.files]] filename = "pyproject.toml" -search = 'version = "2025.04.0"' +search = 'version = "{current_version}"' replace = 'version = "{new_version}"' [[tool.bumpversion.files]] -filename = "src/cpax/__init__.py" -ignore_missing_version = true +filename = "src/cpax/__init__.py" +search = '__version__ = "{current_version}"' +replace = '__version__ = "{new_version}"' diff --git a/.github/workflows/manual-release.yaml b/.github/workflows/manual-release.yaml index 0cf6774..0bcce17 100644 --- a/.github/workflows/manual-release.yaml +++ b/.github/workflows/manual-release.yaml @@ -1,16 +1,23 @@ -# .github/workflows/manual-release.yml name: Manual CalVer Release on: workflow_dispatch: + inputs: + dry_run: + description: 'Dry-run only? (no commit, no push)' + type: boolean + default: true jobs: release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true - - name: Set up Python + - name: Set up Python 3.11 uses: actions/setup-python@v5 with: python-version: '3.11' @@ -18,7 +25,41 @@ jobs: - name: Install bump-my-version run: pip install bump-my-version - - name: Bump version + - name: Compute & (dry-)apply CalVer bump + env: + INPUT_DRY_RUN: ${{ github.event.inputs.dry_run }} run: | - bump-my-version bump patch - git push origin HEAD --follow-tags + set -e + # If `DRY_RUN` was passed via act CLI, keep it; else use the workflow‐dispatch input + DRY_RUN="${DRY_RUN:-$INPUT_DRY_RUN}" + echo "DRY_RUN is: '$DRY_RUN'" + + # 1) Get latest tag or empty + LATEST=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + YEAR=$(date +%Y) # calendar year + MONTH=$(date +%m) # zero-padded month + PREFIX="v${YEAR}.${MONTH}" + + if [[ "$LATEST" == $PREFIX.* ]]; then + SEQ=${LATEST##*.} + NEXT_SEQ=$((SEQ + 1)) + else + NEXT_SEQ=0 + fi + + NEW_VERSION="${YEAR}.${MONTH}.${NEXT_SEQ}" + echo "Next version will be ${NEW_VERSION}" + + # Build the bump command + CMD="bump-my-version bump --new-version ${NEW_VERSION}" + if [[ "$DRY_RUN" == 'true' ]]; then + CMD+=" --dry-run --verbose --no-commit --no-tag" + fi + echo "Running: $CMD" + # expose DRY_RUN to all later steps + echo "DRY_RUN=$DRY_RUN" >> $GITHUB_ENV + $CMD + + - name: Push changes + if: env.DRY_RUN == 'false' + run: git push origin HEAD --follow-tags diff --git a/src/cpax/__init__.py b/src/cpax/__init__.py index 69c1cfd..a6dc150 100644 --- a/src/cpax/__init__.py +++ b/src/cpax/__init__.py @@ -1,7 +1,6 @@ # cpax/__init__.py -from importlib.metadata import version -__version__ = version("cpax") +__version__ = "2025.04.0" # Import submodules but don’t expose specific functions from . import ode