From 7f3808123c88b5cda004476cd3e05db097bb2c05 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 2 Apr 2021 07:12:34 -0400 Subject: [PATCH 01/23] Code cleanup. --- constants.py => commands/_constants.py | 0 utils.py => commands/_utils.py | 0 commands/delete.py | 4 ++-- commands/{update.py => upload.py} | 4 ++-- main.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename constants.py => commands/_constants.py (100%) rename utils.py => commands/_utils.py (100%) rename commands/{update.py => upload.py} (98%) diff --git a/constants.py b/commands/_constants.py similarity index 100% rename from constants.py rename to commands/_constants.py diff --git a/utils.py b/commands/_utils.py similarity index 100% rename from utils.py rename to commands/_utils.py diff --git a/commands/delete.py b/commands/delete.py index 301e285..8ed207b 100644 --- a/commands/delete.py +++ b/commands/delete.py @@ -5,8 +5,8 @@ import asyncclick as click import certifi -from constants import BASE_URL, REPOS_URL -from utils import get_repo +from commands._constants import BASE_URL, REPOS_URL +from commands._utils import get_repo async def get(*, session, url, headers=None, skip_missing=False): diff --git a/commands/update.py b/commands/upload.py similarity index 98% rename from commands/update.py rename to commands/upload.py index 7881fcf..31e174e 100644 --- a/commands/update.py +++ b/commands/upload.py @@ -7,8 +7,8 @@ import asyncclick as click import certifi -from constants import BASE_URL, REPOS_URL -from utils import get_repo +from commands._constants import BASE_URL, REPOS_URL +from commands._utils import get_repo async def get(*, session, url, headers=None, skip_missing=False): diff --git a/main.py b/main.py index 640087a..ceb5436 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ class GithubDeploy(click.MultiCommand): def list_commands(self, ctx): rv = [] for filename in os.listdir(plugin_folder): - if filename.endswith('.py') and not filename.startswith('__init__'): + if filename.endswith('.py') and not filename.startswith('__init__') and not filename.startswith('_'): rv.append(filename[:-3]) rv.sort() return rv From 52c151006928e151eeb3a2a41620f6e71371f611 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 2 Apr 2021 07:13:40 -0400 Subject: [PATCH 02/23] Updated docstrings. --- commands/upload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/upload.py b/commands/upload.py index 31e174e..074a0bd 100644 --- a/commands/upload.py +++ b/commands/upload.py @@ -186,7 +186,7 @@ async def list_repos(*, session, org, token): "--overwrite/--no-overwrite", help="Overwrite existing files.", default=True ) async def main(org, token, source, dest, overwrite): - """Deploy a file to all repositories owned by an organization/user.""" + """Upload a file to all repositories owned by an organization/user.""" # create instance of Semaphore: max concurrent requests. semaphore = asyncio.Semaphore(1000) From cf592940050f5220ecb341f7ce66a1d9f6df1a1d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 2 Apr 2021 11:18:47 -0400 Subject: [PATCH 03/23] Added the minimum python requirements. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index f294507..38d6ef7 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ author_email="jtonye@ymail.com", license="MIT", packages=find_packages(), + python_requires='>=3.6', install_requires=[ "asyncclick", "asyncio", From e9be9e27464794a664910fadda6313a756184c4e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 2 Apr 2021 11:19:44 -0400 Subject: [PATCH 04/23] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 38d6ef7..88c82b3 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ setup( name="github-deploy", - version="0.0.3", + version="0.0.4", description="Deploy yaml files to a large number of repositories in seconds.", long_description=LONG_DESCRIPTION, long_description_content_type=LONG_DESCRIPTION_TYPE, From 23323271f8b204060bf7c6566b0f2e43db5d4379 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 2 Apr 2021 11:38:14 -0400 Subject: [PATCH 05/23] Updated defaults and added a TOKEN env var. --- commands/upload.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/commands/upload.py b/commands/upload.py index 074a0bd..2b1e189 100644 --- a/commands/upload.py +++ b/commands/upload.py @@ -170,6 +170,7 @@ async def list_repos(*, session, org, token): prompt=click.style("Enter your personal access token", bold=True), help="Personal Access token with read and write access to org.", hide_input=True, + envvar='TOKEN', ) @click.option( "--source", @@ -183,7 +184,10 @@ async def list_repos(*, session, org, token): help="Destination path.", ) @click.option( - "--overwrite/--no-overwrite", help="Overwrite existing files.", default=True + "--overwrite/--no-overwrite", + prompt=click.style("Should we overwrite existing contents at this path", fg="cyan"), + help="Overwrite existing files.", + default=False, ) async def main(org, token, source, dest, overwrite): """Upload a file to all repositories owned by an organization/user.""" @@ -237,10 +241,6 @@ async def main(org, token, source, dest, overwrite): return for repo in repos: - click.echo( - "Uploading {path} to repository {repo}...".format(path=dest, repo=repo) - ) - task = asyncio.ensure_future( handle_file_upload( repo=repo, From 4f7cdcca59f773eb408effcc0f4a6d883d243e24 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 2 Apr 2021 12:38:33 -0400 Subject: [PATCH 06/23] Fixed package name. --- {commands => github_deploy}/__init__.py | 0 github_deploy/commands/__init__.py | 1 + {commands => github_deploy/commands}/_constants.py | 0 {commands => github_deploy/commands}/_utils.py | 0 {commands => github_deploy/commands}/delete.py | 5 +++-- {commands => github_deploy/commands}/upload.py | 4 ++-- main.py => github_deploy/main.py | 0 setup.py | 4 +--- 8 files changed, 7 insertions(+), 7 deletions(-) rename {commands => github_deploy}/__init__.py (100%) create mode 100644 github_deploy/commands/__init__.py rename {commands => github_deploy/commands}/_constants.py (100%) rename {commands => github_deploy/commands}/_utils.py (100%) rename {commands => github_deploy/commands}/delete.py (97%) rename {commands => github_deploy/commands}/upload.py (98%) rename main.py => github_deploy/main.py (100%) diff --git a/commands/__init__.py b/github_deploy/__init__.py similarity index 100% rename from commands/__init__.py rename to github_deploy/__init__.py diff --git a/github_deploy/commands/__init__.py b/github_deploy/commands/__init__.py new file mode 100644 index 0000000..0260537 --- /dev/null +++ b/github_deploy/commands/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/commands/_constants.py b/github_deploy/commands/_constants.py similarity index 100% rename from commands/_constants.py rename to github_deploy/commands/_constants.py diff --git a/commands/_utils.py b/github_deploy/commands/_utils.py similarity index 100% rename from commands/_utils.py rename to github_deploy/commands/_utils.py diff --git a/commands/delete.py b/github_deploy/commands/delete.py similarity index 97% rename from commands/delete.py rename to github_deploy/commands/delete.py index 8ed207b..02de2d7 100644 --- a/commands/delete.py +++ b/github_deploy/commands/delete.py @@ -5,8 +5,8 @@ import asyncclick as click import certifi -from commands._constants import BASE_URL, REPOS_URL -from commands._utils import get_repo +from github_deploy.commands._constants import BASE_URL, REPOS_URL +from github_deploy.commands._utils import get_repo async def get(*, session, url, headers=None, skip_missing=False): @@ -146,6 +146,7 @@ async def list_repos(*, session, org, token): prompt=click.style("Enter your personal access token", bold=True), help="Personal Access token with read and write access to org.", hide_input=True, + envvar='TOKEN', ) @click.option( "--dest", diff --git a/commands/upload.py b/github_deploy/commands/upload.py similarity index 98% rename from commands/upload.py rename to github_deploy/commands/upload.py index 2b1e189..9d0bebd 100644 --- a/commands/upload.py +++ b/github_deploy/commands/upload.py @@ -7,8 +7,8 @@ import asyncclick as click import certifi -from commands._constants import BASE_URL, REPOS_URL -from commands._utils import get_repo +from github_deploy.commands._constants import BASE_URL, REPOS_URL +from github_deploy.commands._utils import get_repo async def get(*, session, url, headers=None, skip_missing=False): diff --git a/main.py b/github_deploy/main.py similarity index 100% rename from main.py rename to github_deploy/main.py diff --git a/setup.py b/setup.py index 88c82b3..7ef4314 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,3 @@ -from __future__ import division - import os from setuptools import setup, find_packages @@ -23,7 +21,7 @@ url="https://github.com/tj-python/github-deploy", entry_points={ "console_scripts": [ - "github-deploy=main:main", + "github-deploy=github_deploy.main:main", ], }, keywords=["yaml", "deploy", "poly repository", "github", "single configuration"], From 8ec0b314f9ba5820a403923af5e15c9585b13ec6 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 2 Apr 2021 12:42:01 -0400 Subject: [PATCH 07/23] Removed extra debug line. --- github_deploy/commands/delete.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/github_deploy/commands/delete.py b/github_deploy/commands/delete.py index 02de2d7..f270a1d 100644 --- a/github_deploy/commands/delete.py +++ b/github_deploy/commands/delete.py @@ -189,10 +189,6 @@ async def main(org, token, dest): return for repo in repos: - click.echo( - "Deleting {path} for repository: {repo}...".format(path=dest, repo=repo) - ) - task = asyncio.ensure_future( handle_file_delete( repo=repo, From 200e910af11cbee5365a4fdfb5f173e6f866b2dd Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 6 Apr 2021 14:35:28 -0400 Subject: [PATCH 08/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eec1346..1038d2f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Problem Using [poly repositories](https://github.com/joelparkerhenderson/monorepo_vs_polyrepo#what-is-polyrepo) to manage projects ? -This can introduce a number challenges one of which is maintaining consistency across multiple repositories for files like shared configurations in your organization without introducing git submodules. +This can introduce a number challenges one of which is maintaining consistency across multiple repositories for files like shared configurations in your organization without introducing git submodules or mono repositories with has a more complex deployment configuration. > For example adding a github action or maintaing a consistent pull request template accross your organization. From b67352cf4075e198fe3fa8b1fa130deb32e67952 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 6 Apr 2021 14:35:58 -0400 Subject: [PATCH 09/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1038d2f..1851b3c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Problem Using [poly repositories](https://github.com/joelparkerhenderson/monorepo_vs_polyrepo#what-is-polyrepo) to manage projects ? -This can introduce a number challenges one of which is maintaining consistency across multiple repositories for files like shared configurations in your organization without introducing git submodules or mono repositories with has a more complex deployment configuration. +This can introduce a number challenges one of which is maintaining consistency across multiple repositories for files like shared configurations in your organization without introducing git submodules or mono repositories which has a more complex deployment configuration. > For example adding a github action or maintaing a consistent pull request template accross your organization. From e6b1bedfed6d9054229e7bf644c061f8875f0581 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 8 Apr 2021 08:37:16 -0400 Subject: [PATCH 10/23] Add succient command alias gh --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 7ef4314..fd25ff8 100644 --- a/setup.py +++ b/setup.py @@ -22,6 +22,7 @@ entry_points={ "console_scripts": [ "github-deploy=github_deploy.main:main", + "gh-deploy=github_deploy.main:main", ], }, keywords=["yaml", "deploy", "poly repository", "github", "single configuration"], From e5fa96cd6b7d6739b5d777546e5aba3bf66e0cf0 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 8 Apr 2021 08:39:04 -0400 Subject: [PATCH 11/23] Added bumpversion.cfg --- .bumpversion.cfg | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .bumpversion.cfg diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..71abbeb --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,15 @@ +[bumpversion] +current_version = 2.3.0 +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version="{current_version}" +replace = version="{new_version}" + +[bumpversion:file:model_clone/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 From c7b52ab04344730062e9c60835a4b02bd5d07ecf Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 8 Apr 2021 08:39:25 -0400 Subject: [PATCH 12/23] Added bumpversion.cfg --- .bumpversion.cfg | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 71abbeb..1223f49 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 2.3.0 +current_version = 0.0.4 commit = True tag = True @@ -7,9 +7,5 @@ tag = True search = version="{current_version}" replace = version="{new_version}" -[bumpversion:file:model_clone/__init__.py] -search = __version__ = "{current_version}" -replace = __version__ = "{new_version}" - [bdist_wheel] universal = 1 From 8693edbd1a77127c77eeedf4f1b3a007df87aaf5 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 8 Apr 2021 16:18:13 -0400 Subject: [PATCH 13/23] Changed output messages. --- github_deploy/commands/delete.py | 18 +++++++++++++----- github_deploy/commands/upload.py | 26 ++++++++++++++++++-------- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/github_deploy/commands/delete.py b/github_deploy/commands/delete.py index f270a1d..053548b 100644 --- a/github_deploy/commands/delete.py +++ b/github_deploy/commands/delete.py @@ -116,12 +116,20 @@ async def handle_file_delete( ) if delete_response: - return "Successfully deleted contents at {repo}/{dest}".format( - repo=repo, - dest=dest, + return click.style( + "Successfully deleted contents at {repo}/{dest}".format( + repo=repo, + dest=dest, + ), + fg="green", + bold=True, ) - return "No content found at {repo}/{dest}".format(repo=repo, dest=dest) + return click.style( + "No content found at {repo}/{dest}".format(repo=repo, dest=dest), + fg="blue", + bold=True, + ) async def list_repos(*, session, org, token): @@ -214,7 +222,7 @@ async def main(org, token, dest): err=True, ) else: - click.echo(click.style(result, fg="green", bold=True)) + click.echo(result) if __name__ == "__main__": diff --git a/github_deploy/commands/upload.py b/github_deploy/commands/upload.py index 9d0bebd..1f2612a 100644 --- a/github_deploy/commands/upload.py +++ b/github_deploy/commands/upload.py @@ -113,8 +113,14 @@ async def handle_file_upload( exists = current_sha is not None if exists and not overwrite: - return "Skipped uploading {source} to {repo}: Found an existing copy.".format( - source=source, repo=repo + return click.style( + "Skipped uploading {source} to {repo}/{path}: Found an existing copy.".format( + source=source, + repo=repo, + path=dest, + ), + fg="blue", + bold=True ) else: @@ -141,10 +147,14 @@ async def handle_file_upload( ) if upload_response: - return "Successfully uploaded '{source}' to {repo}/{dest}".format( - source=upload_response["content"]["name"], - repo=repo, - dest=upload_response["content"]["path"], + return click.style( + "Successfully uploaded '{source}' to {repo}/{dest}".format( + source=upload_response["content"]["name"], + repo=repo, + dest=upload_response["content"]["path"], + ), + fg="green", + bold=True ) @@ -185,7 +195,7 @@ async def list_repos(*, session, org, token): ) @click.option( "--overwrite/--no-overwrite", - prompt=click.style("Should we overwrite existing contents at this path", fg="cyan"), + prompt=click.style("Should we overwrite existing contents at this path", fg="blue"), help="Overwrite existing files.", default=False, ) @@ -268,7 +278,7 @@ async def main(org, token, source, dest, overwrite): err=True, ) else: - click.echo(click.style(result, fg="green", bold=True)) + click.echo(result) if __name__ == "__main__": From 7031b4ff0437e0c5dee4a3421bfc3c04fdba5399 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Wed, 28 Apr 2021 06:28:50 -0400 Subject: [PATCH 14/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1851b3c..62d1c89 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Problem Using [poly repositories](https://github.com/joelparkerhenderson/monorepo_vs_polyrepo#what-is-polyrepo) to manage projects ? -This can introduce a number challenges one of which is maintaining consistency across multiple repositories for files like shared configurations in your organization without introducing git submodules or mono repositories which has a more complex deployment configuration. +This can introduce a number challenges one of which is maintaining consistency across multiple repositories, for files like shared configurations without introducing git submodules or mono repositories which requires a more complex deployment configuration. > For example adding a github action or maintaing a consistent pull request template accross your organization. From 7279a98f3f1de763dbfeb47c4fe2e10397370387 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Wed, 28 Apr 2021 06:30:01 -0400 Subject: [PATCH 15/23] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 62d1c89..2044e4f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,9 @@ This can introduce a number challenges one of which is maintaining consistency a > For example adding a github action or maintaing a consistent pull request template accross your organization. +`github-deploy` makes maintaining such configurations as easy as a single command. + + ## Usage ### Creating or Updating files on github From 08ca1a02c0dfb6ffb9a4b122840d3a03f0287d6a Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Wed, 28 Apr 2021 06:30:19 -0400 Subject: [PATCH 16/23] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2044e4f..244492b 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ This can introduce a number challenges one of which is maintaining consistency a > For example adding a github action or maintaing a consistent pull request template accross your organization. +## Solution + `github-deploy` makes maintaining such configurations as easy as a single command. From fede257784b799196c832974dad00e866a8e9255 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 3 May 2021 13:54:37 -0400 Subject: [PATCH 17/23] Updated the .gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 38dee03..7e58086 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,6 @@ dmypy.json .pyre/ # Pycharm -.idea/ \ No newline at end of file +.idea/ + +.envrc From b829fd25c19e1f9b4cf89ff8e7bc284523db9e63 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 25 May 2021 10:30:09 -0400 Subject: [PATCH 18/23] Update README.md --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 244492b..d1ee39d 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ This can introduce a number challenges one of which is maintaining consistency a `github-deploy` makes maintaining such configurations as easy as a single command. +### Alais + +`gh-deploy` + ## Usage @@ -23,13 +27,13 @@ This can introduce a number challenges one of which is maintaining consistency a ```shell script -github-deploy update --org [org] --token [PAT_TOKEN] --dest [LOCATION TO UPLOAD FILE] --source [SOURCE FILE LOCATION] +gh-deploy update --org [org] --token [PAT_TOKEN] --dest [LOCATION TO UPLOAD FILE] --source [SOURCE FILE LOCATION] ``` Example: ```shell script -github-deploy update --org tj-actions --token [PAT_TOKEN] --dest '.github/workflows/auto-approve.yml' --source auto-approve.yml +gh-deploy update --org tj-actions --token [PAT_TOKEN] --dest '.github/workflows/auto-approve.yml' --source auto-approve.yml ``` > NOTE: `auto-approve.yml` is located on your local system. @@ -39,13 +43,13 @@ github-deploy update --org tj-actions --token [PAT_TOKEN] --dest '.github/workfl ```shell script -github-deploy delete --org [org] --token [PAT_TOKEN] --dest [LOCATION TO DELETE] +gh-deploy delete --org [org] --token [PAT_TOKEN] --dest [LOCATION TO DELETE] ``` Example: ```shell script -github-deploy delete --org tj-actions --token [PAT_TOKEN] --dest '.github/auto-approve.yml' +gh-deploy delete --org tj-actions --token [PAT_TOKEN] --dest '.github/auto-approve.yml' ``` From 2daf8a517cb69efd59b29d8fd0f42dae0c09263e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Tue, 25 May 2021 10:30:51 -0400 Subject: [PATCH 19/23] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index d1ee39d..c0ba9df 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,7 @@ This can introduce a number challenges one of which is maintaining consistency a `github-deploy` makes maintaining such configurations as easy as a single command. -### Alais - -`gh-deploy` +**Alais** : `gh-deploy` ## Usage From e31629b556909107d99ac9026c5cee843432a962 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 14 Jun 2021 10:31:11 -0400 Subject: [PATCH 20/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c0ba9df..90888ff 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![PyPI version](https://badge.fury.io/py/github-deploy.svg)](https://badge.fury.io/py/github-deploy) -[![Upload Python Package](https://github.com/tj-python/github-deploy/actions/workflows/python-publish.yml/badge.svg)](https://github.com/tj-python/github-deploy/actions/workflows/python-publish.yml) +[![Upload Python Package](https://github.com/tj-python/github-deploy/actions/workflows/python-publish.yml/badge.svg)](https://github.com/tj-python/github-deploy/actions/workflows/python-publish.yml) [![Downloads](https://pepy.tech/badge/github-deploy)](https://pepy.tech/project/github-deploy) # github-deploy From 93014c0396c6be8dd52f255a7c4aa8f1e4897a7e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 30 Jul 2021 06:06:31 -0400 Subject: [PATCH 21/23] Added support for uploading to only public repositories. --- github_deploy/commands/_utils.py | 4 ++++ github_deploy/commands/upload.py | 19 +++++++++++++------ github_deploy/main.py | 4 ++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/github_deploy/commands/_utils.py b/github_deploy/commands/_utils.py index 9d90cb5..67cdb6b 100644 --- a/github_deploy/commands/_utils.py +++ b/github_deploy/commands/_utils.py @@ -1,2 +1,6 @@ def get_repo(*, org, project): return "{org}/{project}".format(project=project, org=org) + + +def can_upload(*, repo, include_private): + return True if include_private and repo['private'] == True else not repo['private'] diff --git a/github_deploy/commands/upload.py b/github_deploy/commands/upload.py index 1f2612a..00ff12f 100644 --- a/github_deploy/commands/upload.py +++ b/github_deploy/commands/upload.py @@ -8,7 +8,7 @@ import certifi from github_deploy.commands._constants import BASE_URL, REPOS_URL -from github_deploy.commands._utils import get_repo +from github_deploy.commands._utils import get_repo, can_upload async def get(*, session, url, headers=None, skip_missing=False): @@ -199,7 +199,13 @@ async def list_repos(*, session, org, token): help="Overwrite existing files.", default=False, ) -async def main(org, token, source, dest, overwrite): +@click.option( + "--private/--no-private", + prompt=click.style("Should we Include private repositories", bold=True), + help="Upload files to private repositories.", + default=True, +) +async def main(org, token, source, dest, overwrite, private): """Upload a file to all repositories owned by an organization/user.""" # create instance of Semaphore: max concurrent requests. semaphore = asyncio.Semaphore(1000) @@ -209,13 +215,14 @@ async def main(org, token, source, dest, overwrite): async with aiohttp.ClientSession() as session: response = await list_repos(org=org, token=token, session=session) repos = [ - get_repo(org=org, project=v["name"]) - for v in response["items"] - if not v["archived"] + get_repo(org=org, project=r["name"]) + for r in response["items"] + if not r["archived"] and can_upload(repo=r, include_private=private) ] + repo_type = 'public and private' if private else 'public' click.echo( click.style( - "Found '{}' repositories non archived repositories:".format(len(repos)), + "Found '{}' repositories non archived {} repositories:".format(len(repos), repo_type), fg="green", ) ) diff --git a/github_deploy/main.py b/github_deploy/main.py index ceb5436..bec9463 100644 --- a/github_deploy/main.py +++ b/github_deploy/main.py @@ -5,7 +5,7 @@ class GithubDeploy(click.MultiCommand): - + def list_commands(self, ctx): rv = [] for filename in os.listdir(plugin_folder): @@ -13,7 +13,7 @@ def list_commands(self, ctx): rv.append(filename[:-3]) rv.sort() return rv - + def get_command(self, ctx, name): ns = {} fn = os.path.join(plugin_folder, name + '.py') From 8742b8d9cae603ddbefabbf4f38ef992cf2550c3 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 30 Jul 2021 06:29:32 -0400 Subject: [PATCH 22/23] Updated deployment. --- .github/workflows/deploy.yml | 56 ++++++++++++++++++++++++++ .github/workflows/python-publish.yml | 31 --------------- Makefile | 59 ++++++++++++++++++++++++++++ setup.py | 10 +++++ 4 files changed, 125 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/python-publish.yml create mode 100644 Makefile diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..d2d45d1 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,56 @@ +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Run semver-diff + id: semver-diff + uses: tj-actions/semver-diff@v1.2.0 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.6.x' + + - name: Upgrade pip + run: pip install -U pip + + - name: Install dependencies + run: make install-deploy + + - name: Setup git + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + - name: bumpversion + run: | + make increase-version PART="${{ steps.semver-diff.outputs.release_type }}" + + - name: Build and publish + run: make release + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + + - name: Generate CHANGELOG + uses: tj-actions/github-changelog-generator@v1.8 + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v3 + with: + base: "main" + title: "Upgraded ${{ steps.semver-diff.outputs.old_version }} → ${{ steps.semver-diff.outputs.new_version }}" + branch: "chore/upgrade-${{ steps.semver-diff.outputs.old_version }}-to-${{ steps.semver-diff.outputs.new_version }}" + commit-message: "Upgraded from ${{ steps.semver-diff.outputs.old_version }} → ${{ steps.semver-diff.outputs.new_version }}" + body: "View [CHANGES](https://github.com/${{ github.repository }}/compare/${{ steps.semver-diff.outputs.old_version }}...${{ steps.semver-diff.outputs.new_version }})" + token: ${{ secrets.PAT_TOKEN }} diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index 1a03a7b..0000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,31 +0,0 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Upload Python Package - -on: - release: - types: [created] - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2904151 --- /dev/null +++ b/Makefile @@ -0,0 +1,59 @@ +# Self-Documented Makefile see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html + +.DEFAULT_GOAL := help +PART := minor + +# Put it first so that "make" without argument is like "make help". +help: + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-32s-\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +guard-%: ## Checks that env var is set else exits with non 0 mainly used in CI; + @if [ -z '${${*}}' ]; then echo 'Environment variable $* not set' && exit 1; fi + +# -------------------------------------------------------- +# ------- Python package (pip) management commands ------- +# -------------------------------------------------------- + +clean: clean-build clean-pyc ## remove all build and Python artifacts + +clean-build: ## remove build artifacts + @rm -fr build/ + @rm -fr dist/ + @rm -fr .eggs/ + @find . -name '*.egg-info' -exec rm -fr {} + + @find . -name '*.egg' -exec rm -f {} + + +clean-pyc: ## remove Python file artifacts + @find . -name '*.pyc' -exec rm -f {} + + @find . -name '*.pyo' -exec rm -f {} + + @find . -name '*~' -exec rm -f {} + + @find . -name '__pycache__' -exec rm -fr {} + || true + +lint: ## check style with flake8 + @flake8 github_deploy + +release: dist ## package and upload a release + @twine upload dist/* + +dist: clean install-deploy ## builds source and wheel package + @pip install twine==3.4.1 + @python setup.py sdist bdist_wheel + +increase-version: guard-PART ## Increase project version + @bump2version $(PART) + @git switch -c main + +install-wheel: clean ## Install wheel + @echo "Installing wheel..." + @pip install wheel + +install: install-wheel ## install the package to the active Python's site-packages + @pip install . + +install-deploy: install-wheel + @pip install -e .'[deploy]' + +migrations: + @python manage.py makemigrations + +.PHONY: clean clean-build clean-pyc dist increase-version install-wheel install install-deploy increase-version lint release migrations diff --git a/setup.py b/setup.py index fd25ff8..95b6c50 100644 --- a/setup.py +++ b/setup.py @@ -11,6 +11,15 @@ else: LONG_DESCRIPTION = "" +deploy_requires = [ + "bump2version", + "readme_renderer[md]", +] + +extras_require = { + "deploy": deploy_requires, +} + setup( name="github-deploy", @@ -31,6 +40,7 @@ license="MIT", packages=find_packages(), python_requires='>=3.6', + extras_require=extras_require, install_requires=[ "asyncclick", "asyncio", From 4911278050f569cfc6852ab66520d64da5abd8ea Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 30 Jul 2021 06:37:56 -0400 Subject: [PATCH 23/23] Update README.md --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/README.md b/README.md index 90888ff..7079482 100644 --- a/README.md +++ b/README.md @@ -51,5 +51,56 @@ gh-deploy delete --org tj-actions --token [PAT_TOKEN] --dest '.github/auto-appro ``` + +## COMMAND +`gh-deploy --help` + +``` +Usage: gh-deploy [OPTIONS] COMMAND [ARGS]... + + Deploy changes to multiple github repositories using a single command. + +Options: + --help Show this message and exit. + +Commands: + delete Delete a file in all repositories owned by an organization/user. + upload Upload a file to all repositories owned by an organization/user. + +``` + +`gh-deploy upload --help` + +``` +Usage: gh-deploy upload [OPTIONS] + + Upload a file to all repositories owned by an organization/user. + +Options: + --org TEXT The github organization. + --token TEXT Personal Access token with read and write + access to org. + + --source PATH Source file. + --dest TEXT Destination path. + --overwrite / --no-overwrite Overwrite existing files. + --private / --no-private Upload files to private repositories. + --help Show this message and exit. +``` + +`gh-deploy delete --help` + +``` +Usage: gh-deploy delete [OPTIONS] + + Delete a file in all repositories owned by an organization/user. + +Options: + --org TEXT The github organization. + --token TEXT Personal Access token with read and write access to org. + --dest TEXT Destination path to delete. + --help Show this message and exit. +``` + ### Resources - http://www.gigamonkeys.com/mono-vs-multi/ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy