-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize gh-pages branch in the post hook
- Loading branch information
Showing
2 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ class Dependency: | |
class Query: | ||
id: str | ||
interactive: bool | ||
default: bool | ||
prompt: str | ||
command: str | ||
autorun: bool | ||
|
@@ -64,6 +65,7 @@ class Query: | |
Query( | ||
id="git_init", | ||
interactive=True, | ||
default=True, | ||
prompt="Initializing git repository...", | ||
command="git init\n" | ||
"git add --all\n" | ||
|
@@ -73,23 +75,37 @@ class Query: | |
Query( | ||
id="git_remote", | ||
interactive=True, | ||
default=True, | ||
prompt="Adding git remote...", | ||
command="git remote add origin [email protected]:{{ cookiecutter.github_user }}/{{ cookiecutter.repository_name }}.git", | ||
autorun=True, | ||
dependencies=[ | ||
Dependency(id="git_init", expected=True), | ||
], | ||
), | ||
Query( | ||
id="git_push_main", | ||
interactive=True, | ||
default=True, | ||
prompt="Pushing default branch to existing remote...", | ||
command="git push -u origin HEAD", | ||
autorun=True, | ||
dependencies=[ | ||
Dependency(id="git_remote", expected=True), | ||
], | ||
), | ||
Query( | ||
id="conda_env", | ||
interactive=True, | ||
default=True, | ||
prompt="Creating conda environment...", | ||
command="conda env create -f env.yaml", | ||
autorun=True, | ||
), | ||
Query( | ||
id="precommit_install", | ||
interactive=False, | ||
interactive=True, | ||
default=True, | ||
prompt="Installing pre-commits...", | ||
command="conda run -n {{ cookiecutter.conda_env_name }} pre-commit install", | ||
autorun=True, | ||
|
@@ -98,9 +114,35 @@ class Query: | |
Dependency(id="conda_env", expected=True), | ||
], | ||
), | ||
Query( | ||
id="mike_init", | ||
interactive=True, | ||
default=True, | ||
prompt="Initializing gh-pages branch for GitHub Pages...", | ||
command="conda run -n {{ cookiecutter.conda_env_name }} mike deploy --update-aliases 0.0 latest\n" | ||
"conda run -n {{ cookiecutter.conda_env_name }} mike set-default latest", | ||
autorun=True, | ||
dependencies=[ | ||
Dependency(id="conda_env", expected=True), | ||
Dependency(id="git_init", expected=True), | ||
], | ||
), | ||
Query( | ||
id="mike_push", | ||
interactive=True, | ||
default=True, | ||
prompt="Pushing 'gh-pages' branch to existing remote...", | ||
command="git push origin gh-pages", | ||
autorun=True, | ||
dependencies=[ | ||
Dependency(id="mike_init", expected=True), | ||
Dependency(id="git_remote", expected=True), | ||
], | ||
), | ||
Query( | ||
id="conda_activate", | ||
interactive=False, | ||
default=True, | ||
prompt="Activate your conda environment with:", | ||
command="cd {{ cookiecutter.repository_name }}\n" | ||
"conda activate {{ cookiecutter.conda_env_name }}\n" | ||
|
@@ -137,7 +179,7 @@ def setup(setup_commands) -> None: | |
f'{textwrap.indent(query.command, prefix=" ")}\n' | ||
f"\n" | ||
f"Execute?", | ||
default=True, | ||
default=query.default, | ||
) | ||
else: | ||
print( | ||
|
@@ -165,9 +207,15 @@ def setup(setup_commands) -> None: | |
setup(setup_commands=SETUP_COMMANDS) | ||
|
||
print( | ||
"\nYou are all set!\n" | ||
"\nYou are all set!\n\n" | ||
"Remember that if you use PyCharm, you must:\n" | ||
' - Mark the "src" directory as "Sources Root".\n' | ||
' - Enable "Emulate terminal in output console" in the run configuration.\n' | ||
) | ||
print( | ||
"Remember to:\n" | ||
" - Enable the GitHub Actions in the repository.\n" | ||
' - Enable the Github Pages in the "gh-pages" branch, auto-published on each release.' | ||
) | ||
|
||
print("Have fun! :]") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,7 @@ jobs: | |
run: | | ||
git config user.name ci-bot | ||
git config user.email [email protected] | ||
mike deploy --push --rebase --update-aliases ${RELEASE_TAG_VERSION} latest | ||
mike deploy --rebase --update-aliases ${RELEASE_TAG_VERSION} latest | ||
mike set-default --push --rebase latest | ||
# Uncomment to publish on PyPI on release | ||
|