-
Notifications
You must be signed in to change notification settings - Fork 0
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 #78 from dwhswenson/cli
Start to CLI
- Loading branch information
Showing
9 changed files
with
185 additions
and
6 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,5 @@ | ||
INSTALL_AUTORELEASE="python -m pip install autorelease==0.2.3" | ||
if [ -f autorelease-env.sh ]; then | ||
source autorelease-env.sh | ||
fi | ||
|
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,31 @@ | ||
name: Autorelease | ||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
deploy_pypi: | ||
runs-on: ubuntu-latest | ||
name: "Deploy to PyPI" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.x" | ||
- run: | # TODO: move this to an action | ||
source ./.github/workflows/autorelease-default-env.sh | ||
cat autorelease-env.sh >> $GITHUB_ENV | ||
eval $INSTALL_AUTORELEASE | ||
name: "Install autorelease" | ||
- run: | | ||
python -m pip install twine wheel | ||
name: "Install release tools" | ||
- run: | | ||
python setup.py sdist bdist_wheel | ||
twine check dist/* | ||
name: "Build and check package" | ||
- uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
password: ${{ secrets.pypi_password }} | ||
name: "Deploy to testpypi" | ||
|
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,27 @@ | ||
name: Autorelease | ||
on: | ||
push: | ||
branches: | ||
- stable | ||
|
||
jobs: | ||
release-gh: | ||
runs-on: ubuntu-latest | ||
name: "Cut release" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.7" | ||
- run: | # TODO: move this to an action | ||
source ./.github/workflows/autorelease-default-env.sh | ||
cat autorelease-env.sh >> $GITHUB_ENV | ||
eval $INSTALL_AUTORELEASE | ||
name: "Install autorelease" | ||
- run: | | ||
VERSION=`python setup.py --version` | ||
PROJECT=`python setup.py --name` | ||
echo $PROJECT $VERSION | ||
autorelease-release --project $PROJECT --version $VERSION --token $AUTORELEASE_TOKEN | ||
env: | ||
AUTORELEASE_TOKEN: ${{ secrets.AUTORELEASE_TOKEN }} |
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,56 @@ | ||
name: "Autorelease" | ||
on: | ||
pull_request: | ||
branches: | ||
- stable | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
deploy_testpypi: | ||
runs-on: ubuntu-latest | ||
name: "Deployment test" | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.x" | ||
- run: | # TODO: move this to an action | ||
source ./.github/workflows/autorelease-default-env.sh | ||
cat autorelease-env.sh >> $GITHUB_ENV | ||
eval $INSTALL_AUTORELEASE | ||
name: "Install autorelease" | ||
- run: | | ||
python -m pip install twine wheel | ||
name: "Install release tools" | ||
- run: | | ||
bump-dev-version | ||
python setup.py --version | ||
name: "Bump testpypi dev version" | ||
- run: | | ||
python setup.py sdist bdist_wheel | ||
twine check dist/* | ||
name: "Build and check package" | ||
- uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
password: ${{ secrets.testpypi_password }} | ||
repository_url: https://test.pypi.org/legacy/ | ||
name: "Deploy to testpypi" | ||
test_testpypi: | ||
runs-on: ubuntu-latest | ||
name: "Test deployed" | ||
needs: deploy_testpypi | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.x" | ||
- run: | # TODO: move this to an action | ||
source ./.github/workflows/autorelease-default-env.sh | ||
cat autorelease-env.sh >> $GITHUB_ENV | ||
eval $INSTALL_AUTORELEASE | ||
name: "Install autorelease" | ||
- run: test-testpypi | ||
|
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,22 @@ | ||
import click | ||
|
||
from autorelease.scripts.vendor import vendor_actions | ||
|
||
@click.group() | ||
def cli(): | ||
pass | ||
|
||
|
||
@click.group() | ||
def vendor(): | ||
pass | ||
|
||
@vendor.command() | ||
def actions(): | ||
print("vendoring actions") | ||
vendor_actions(base_path='.') | ||
|
||
cli.add_command(vendor) | ||
|
||
if __name__ == "__main__": | ||
cli() |
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,23 @@ | ||
import pkg_resources | ||
import pathlib | ||
import shutil | ||
|
||
import click | ||
|
||
def vendor(resources, base_path, relative_target_dir): | ||
for resource in resources: | ||
orig_loc = pkg_resources.resource_filename('autorelease', resource) | ||
name = pathlib.Path(orig_loc).name | ||
target_dir = base_path / relative_target_dir | ||
target_dir.mkdir(parents=True, exist_ok=True) | ||
target_loc = base_path / relative_target_dir / name | ||
# print(f"cp {orig_loc} {target_loc}") | ||
shutil.copy(orig_loc, target_loc) | ||
|
||
def vendor_actions(base_path): | ||
resources = ['autorelease-default-env.sh', 'autorelease-prep.yml', | ||
'autorelease-gh-rel.yml', 'autorelease-deploy.yml'] | ||
resources = ['gh_actions_stages/' + res for res in resources] | ||
target_dir = pathlib.Path('.github/workflows') | ||
vendor(resources, base_path, target_dir) | ||
|
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