Skip to content

Commit

Permalink
Create tag and release
Browse files Browse the repository at this point in the history
  • Loading branch information
anevis committed Apr 8, 2024
1 parent 6ccca83 commit 40c1ba6
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
35 changes: 26 additions & 9 deletions .github/workflows/cd.yaml → .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
name: CD Pipeline
run-name: CD 📦🚀
name: Release Pipeline
run-name: Release 📦🚀

on:
workflow_run:
workflows: ["CI Pipeline"]
types: [completed]
workflow_dispatch:
branches:
- "main"
paths:
- "src/**"
- "requirements.txt"
- "LICENSE"

jobs:
CD:
Expand All @@ -27,6 +21,29 @@ jobs:
uses: jetpack-io/[email protected]
- name: Install all dependencies 📦
run: devbox run install
- name: Tag Name
run: export TAG_NAME="0.1.$(date +%s)" && echo "🏷️ Tag name is $TAG_NAME"
- name: Create Tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/$TAG_NAME',
sha: context.sha
})
- name: Create Release
uses: actions/github-script@v7
with:
script: |
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: '$TAG_NAME',
name: 'Release $TAG_NAME',
generate_release_notes: true
})
- name: 📦 Package
run: devbox run build
- name: 🚀 Publish to PyPI
Expand Down
17 changes: 11 additions & 6 deletions src/yaml_to_markdown/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,26 @@ def main(
json_file: Optional[str],
show_help: bool,
) -> None:
if show_help or (yaml_file is None and json_file is None) or output_file is None:
if show_help:
_help()
return
_verify_inputs(output_file=output_file, yaml_file=yaml_file, json_file=json_file)

convert(output_file=output_file, yaml_file=yaml_file, json_file=json_file)


def _verify_inputs(
output_file: str, yaml_file: Optional[str], json_file: Optional[str]
) -> None:
if (yaml_file is None and json_file is None) or output_file is None:
_help()
exit(1)


def convert(
output_file: str, yaml_file: Optional[str] = None, json_file: Optional[str] = None
) -> None:
if yaml_file is None and json_file is None or output_file is None:
_help()
raise RuntimeError(
"One of yaml_file or json_file is required along with output_file"
)
_verify_inputs(output_file=output_file, yaml_file=yaml_file, json_file=json_file)

data = _get_json_data(json_file) if json_file else _get_yaml_data(yaml_file)
with io.open(output_file, "w", encoding="utf-8") as md_file:
Expand Down
4 changes: 1 addition & 3 deletions src/yaml_to_markdown/convert_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

def test_convert_with_no_file() -> None:
# Execute
with pytest.raises(
RuntimeError, match="One of yaml_file or json_file is required."
):
with pytest.raises(SystemExit):
convert(output_file="some.md")


Expand Down
2 changes: 1 addition & 1 deletion src/yaml_to_markdown/md_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def set_custom_section_processors(
custom_processors: Dict[
str, Callable[[MDConverter, Optional[str], Any, int], str]
],
):
) -> None:
"""
Set custom section processors, the key must match a section name/key
and the processor must take 4 arguments and return a Markdown string:
Expand Down
2 changes: 1 addition & 1 deletion src/yaml_to_markdown/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class TestUtils:
def test_convert_to_title_case(self):
def test_convert_to_title_case(self) -> None:
assert convert_to_title_case("test-case") == "Test Case"

0 comments on commit 40c1ba6

Please sign in to comment.