Skip to content

Commit

Permalink
Update build script to properly add changed files to git during the r…
Browse files Browse the repository at this point in the history
…elease process (#21)

* build: Remove the assets from semantic-release, they don't work around the issue of the tool not adding things to git properly.

* build: Modify script to properly add changed files to git before semantic-release commits the changes
  • Loading branch information
nfelt14 authored Aug 27, 2024
1 parent fa8b441 commit 8aae5cb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Valid subsections within a version are:

Things to be included in the next release go here.

### Fixed

- Actually fixed the issue with the semantic-release configuration preventing updated files with each new release version from being properly updated in the repo as a part of the release.

---

## v1.0.1 (2024-08-27)
Expand Down
6 changes: 0 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ order-by-type = false
]

[tool.semantic_release]
assets = [
".github",
"README.md",
"actions",
"workflows"
]
build_command = """
python -m scripts.bump_version_in_files
"""
Expand Down
2 changes: 2 additions & 0 deletions scripts/bump_version_in_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import os
import re
import subprocess

from pathlib import Path

Expand Down Expand Up @@ -52,6 +53,7 @@ def update_github_actions_version(filepath: Path, incoming_version: str) -> None
)
print(f'Bumping version in "{filepath}" to', incoming_version)
filepath.write_text(updated_content)
subprocess.check_call(["git", "add", filepath.as_posix()]) # noqa: S603,S607
else:
print(f'No GitHub Workflow/Action usage found in "{filepath}", skipping update.')

Expand Down
9 changes: 9 additions & 0 deletions tests/test_bump_version_in_files.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
"""Test the bump_version_in_files module."""

from pathlib import Path
from typing import Generator
from unittest.mock import MagicMock, patch

import pytest

from scripts.bump_version_in_files import get_file_paths, update_github_actions_version


@pytest.fixture(autouse=True)
def mock_subprocess_check_call() -> Generator[None, None, None]:
"""Mock subprocess.check_call for all tests."""
with patch("subprocess.check_call", MagicMock(return_value=None)):
yield


@pytest.fixture()
def temporary_directory(tmp_path: Path) -> Path:
"""Create a temporary directory."""
Expand Down

0 comments on commit 8aae5cb

Please sign in to comment.