-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from kylef/kylef/release-config
Support Releaser Configuration
- Loading branch information
Showing
12 changed files
with
214 additions
and
72 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
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Hooks Releaser | ||
|
||
By creating a `.maintain.yml` file in the root of your repository, you can add | ||
hooks to various stages of the release process. | ||
|
||
```yaml | ||
release: | ||
hooks: | ||
bump: | ||
pre: | ||
- echo 'version will be bumped' | ||
post: | ||
- echo 'version was bumped' | ||
release: | ||
pre: | ||
- echo 'version will be released' | ||
post: | ||
- echo 'version was released' | ||
``` |
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import subprocess | ||
|
||
import click | ||
|
||
from maintain.release.base import Releaser | ||
|
||
|
||
class HookReleaser(Releaser): | ||
name = 'Hooks' | ||
|
||
@classmethod | ||
def detect(cls): | ||
return True | ||
|
||
def __init__(self, config): | ||
self.bump_commands = [] | ||
self.release_commands = [] | ||
|
||
self.pre_bump_commands = config.get('bump', {}).get('pre', []) | ||
self.post_bump_commands = config.get('bump', {}).get('post', []) | ||
|
||
self.pre_release_commands = config.get('publish', {}).get('pre', []) | ||
self.post_release_commands = config.get('publish', {}).get('post', []) | ||
|
||
def pre_bump(self, new_version): | ||
self.execute_hooks('pre bump', self.pre_bump_commands) | ||
|
||
def bump(self, new_version): | ||
self.execute_hooks('bump', self.bump_commands) | ||
|
||
def post_bump(self, new_version): | ||
self.execute_hooks('post bump', self.post_bump_commands) | ||
|
||
def pre_release(self, new_version): | ||
self.execute_hooks('pre release', self.pre_release_commands) | ||
|
||
def release(self, new_version): | ||
self.execute_hooks('release', self.release_commands) | ||
|
||
def post_release(self, new_version): | ||
self.execute_hooks('post release', self.post_release_commands) | ||
|
||
def execute_hooks(self, phase, commands): | ||
if len(commands) > 0: | ||
click.echo('Running {} hooks'.format(phase)) | ||
|
||
for hook in commands: | ||
click.echo('- ' + hook) | ||
subprocess.check_output(hook, shell=True) |
Oops, something went wrong.