Skip to content
This repository has been archived by the owner on Jun 23, 2020. It is now read-only.

Commit

Permalink
Run git commands through the shell (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcannon authored Mar 30, 2020
1 parent 671d83d commit af3ac04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ jobs:
with:
changelog-path: CHANGES.md
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
ACTIONS_STEP_DEBUG: "true"
17 changes: 14 additions & 3 deletions release_often/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ def update_version():
build_tool, version_file = version.find_details(actions.workspace())
if build_tool is None:
error("build tool not detected; unable to update version")
else:
actions.command("debug", f"Build tool is {build_tool.__name__}")
actions.command("debug", f"Version found in {version_file!r}")
file_contents = version_file.read_text(encoding="utf-8")
current_version = build_tool.read_version(file_contents)
actions.command("debug", f"Current/old version is {current_version}")
new_version = version.bump_by_label(actions.event(), current_version)
actions.command("debug", f"New version is {new_version}")
new_contents = build_tool.change_version(
file_contents, current_version, new_version
)
Expand All @@ -39,6 +44,7 @@ def update_version():
def update_changelog(path, new_version):
if not path.exists():
error(f"The path to the changelog does not exist: {path!r}")
actions.command("debug", f"Changelog file path is {path}")
new_entry = changelog.entry(path.suffix, new_version, actions.event())
current_changelog = path.read_text(encoding="utf-8")
path.write_text(new_entry + current_changelog, encoding="utf-8")
Expand All @@ -47,6 +53,7 @@ def update_changelog(path, new_version):
def build():
source_dir = actions.workspace()
output_dir = source_dir / "dist"
actions.command("debug", f"Writing build artifacts to {output_dir!r}")
for builder in (pep517.envbuild.build_sdist, pep517.envbuild.build_wheel):
builder(source_dir, output_dir)
# https://github.com/python-poetry/poetry/issues/769
Expand All @@ -59,15 +66,19 @@ def build():
def commit(new_version):
os.chdir(actions.workspace())
subprocess.run(
["/usr/bin/git", "config", "--local", "user.email", "action@github.com"],
["git", "config", "--local", "user.email", "action@github.com"],
check=True,
shell=True,
)
subprocess.run(
["/usr/bin/git", "config", "--local", "user.name", "GitHub Action"], check=True
["git", "config", "--local", "user.name", "GitHub Action"],
check=True,
shell=True,
)
subprocess.run(
["/usr/bin/git", "commit", "-a", "-m", f"Updates for v{new_version}"],
["git", "commit", "-a", "-m", f"Updates for v{new_version}"],
check=True,
shell=True,
)


Expand Down

0 comments on commit af3ac04

Please sign in to comment.