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 19563c6
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 53 deletions.
37 changes: 0 additions & 37 deletions .github/workflows/cd.yaml

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release Pipeline
run-name: Release 📦🚀

on:
workflow_dispatch:
branches:
- "main"

jobs:
Release:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: Installing Devbox ⚙️
uses: jetpack-io/[email protected]
- name: Install all dependencies 📦
run: devbox run install
- name: Release Version
run: export RELEASE_VERSION="0.1.$(date +%s)" && echo "🏷️ Tag name is ${RELEASE_VERSION}"
- 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/v${{ env.RELEASE_VERSION }}',
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: 'v${{ env.RELEASE_VERSION }}',
name: 'Release v${{ env.RELEASE_VERSION }}',
generate_release_notes: true
})
- name: 📦 Package
env:
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
run: devbox run build
# - name: 🚀 Publish to PyPI
# run: devbox run publish
# env:
# TWINE_USERNAME: "__token__"
# TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
- run: echo "🍏 This job's status is ${{ job.status }}."
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import os
from typing import List

from setuptools import setup, find_packages
import calendar
import time

gmt = time.gmtime()
ts = calendar.timegm(gmt)
version = os.environ.get("RELEASE_VERSION")

with open("README.md", "r") as fh:
long_description = fh.read()
Expand All @@ -27,7 +25,7 @@

setup(
name="yaml-to-markdown",
version=f"0.1.{ts}",
version=version,
description="Converts a YAML/JSON file or python Dict/List to a Markdown file",
packages=find_packages(where="src"),
package_dir={"": "src"},
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 19563c6

Please sign in to comment.