Skip to content

Commit

Permalink
Merge pull request #108 from dwhswenson/release-0.4.0
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
dwhswenson authored Jan 9, 2023
2 parents 2c159a1 + 323f2f1 commit 7d07246
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 17 deletions.
40 changes: 40 additions & 0 deletions .autorelease/autorelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# project configuration
project:
project_name: Autorelease
repo_owner: dwhswenson
repo_name: autorelease

# repo configuration: how you organize releases and the repo
repo:
# these are relative to where you run the script from
repo-path: '.'
setup-path: '.'
release-branches:
- stable
release-tag: "v{BASE_VERSION}"

# writing release notes
notes:
labels:
- label: enhancement
heading: New features
- label: bugfix
heading: Bugs fixed
- label: misc PR
heading: Miscellaneous improvements

standard_contributors:
- dwhswenson

# running release checks
release-check:
versions:
- setup-cfg
- conda: devtools/conda-recipe/meta.yaml
skip: []


# TODO: this replaces various environment variables
env:
package-import-name: 'autorelease'
dry: ""
10 changes: 6 additions & 4 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ jobs:
strategy:
matrix:
CONDA_PY:
- 3.9
- 3.8
- 3.7
- 2.7
- "3.11"
- "3.10"
- "3.9"
- "3.8"
- "3.7"

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -59,3 +60,4 @@ jobs:
python -c "import autorelease"
autorelease-release -h
python release_check.py
autorelease check
10 changes: 5 additions & 5 deletions autorelease-travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AUTORELEASE v0.3.2
# AUTORELEASE v0.4.0
# for nonrelease, use @main
# for release, use v${VERSION}, e.g., v1.0.0
stages:
Expand All @@ -9,7 +9,7 @@ stages:
- deploy pypi

import:
- dwhswenson/autorelease:travis_stages/deploy_testpypi.yml@v0.3.2
- dwhswenson/autorelease:travis_stages/test_testpypi.yml@v0.3.2
- dwhswenson/autorelease:travis_stages/cut_release.yml@v0.3.2
- dwhswenson/autorelease:travis_stages/deploy_pypi.yml@v0.3.2
- dwhswenson/autorelease:travis_stages/deploy_testpypi.yml@v0.4.0
- dwhswenson/autorelease:travis_stages/test_testpypi.yml@v0.4.0
- dwhswenson/autorelease:travis_stages/cut_release.yml@v0.4.0
- dwhswenson/autorelease:travis_stages/deploy_pypi.yml@v0.4.0
4 changes: 2 additions & 2 deletions autorelease/scripts/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def checker_from_yaml_dict(release_check):
return checker


def run_checks(yml, branch=None, event=None, allow_patch_skip=False):
dct = yaml.load(yml, Loader=yaml.FullLoader)
def run_checks(dct, branch=None, event=None, allow_patch_skip=False):
release_check = dct['release-check']
release_check.update(dct['repo'])
checker = checker_from_yaml_dict(release_check)
if branch is None and event is None:
branch, event = checker.get_branch_event_from_github_env()
Expand Down
69 changes: 67 additions & 2 deletions autorelease/scripts/cli.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,83 @@
import os
import click
import yaml

from autorelease.scripts.vendor import vendor_actions
from autorelease.scripts.check import run_checks
from autorelease import ReleaseNoteWriter


def _find_first_file(pathlist):
for p in pathlist:
if os.path.exists(p):
return p
return None

def load_yaml(user_input, default_pathlist):
if user_input is not None:
dct = yaml.load(user_input, Loader=yaml.FullLoader)
else:
filename = _find_first_file(default_pathlist)
if filename is None:
raise RuntimeError("No config file could be found")
with open(filename, mode='r') as f:
dct = yaml.load(f, Loader=yaml.FullLoader)

return dct

def load_config(user_input):
paths = [
".autorelease.yml",
"autorelease.yml",
os.path.join(".autorelease", "autorelease.yml"),
os.path.join(".autorelease", "conf.yml"),
]
return load_yaml(user_input, paths)

def load_auth(user_input):
paths = [
os.path.join(os.path.expanduser("~"), ".autorelease-auth.yml"),
os.path.join(".autorelease", "auth.yml"),
os.path.join(".autorelease", "autorelease-auth.yml"),
".autorelease-auth.yml",
"autorelease-auth.yml",
]
return load_yaml(user_input, paths)


@click.group()
def cli():
pass

@cli.command()
@click.option('--conf', type=click.File('r'), default='autorelease.yml')
@click.option('--conf', type=click.File('r'))
@click.option('--branch', default=None)
@click.option('--event', default=None)
def check(conf, branch, event):
run_checks(conf, branch, event)
dct = load_config(conf)
run_checks(dct, branch, event)

@cli.command()
@click.option('--conf', type=click.File('r'))
def config(conf):
from pprint import pprint
config = load_config(conf)
pprint(config)


@cli.command()
@click.option('--conf', type=click.File('r'))
@click.option('--auth', type=click.File('r'))
@click.option('--since-release', type=str, default=None)
@click.option('-o', '--output', type=str)
def notes(conf, auth, since_release, output):
config = load_config(conf)
github_user = load_auth(auth)
notes_conf = config['notes']
notes_conf.update(github_user)
notes_conf['project'] = config['project']
writer = ReleaseNoteWriter(config=notes_conf)
writer.write_release_notes(outfile=output)

@click.group()
def vendor():
Expand Down
2 changes: 1 addition & 1 deletion autorelease/scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def main():
repo=repo,
github_user=github_user
)

# testing
expected_pr = releaser.find_relevant_pr()
print("Expected PR: " + str(expected_pr))
Expand Down
5 changes: 4 additions & 1 deletion autorelease/scripts/vendor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import string
import pathlib
try:
import pathlib
except ImportError: # py2
import pathlib2
import pkg_resources
from packaging.version import Version
import autorelease
Expand Down
11 changes: 11 additions & 0 deletions autorelease/version_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@
from autorelease.version import get_setup_version # reuse the vendored
from autorelease.utils import conda_recipe_version

import importlib

def import_and_get(fully_qualified):
path = fully_qualified.split('.')
to_load = path.pop(-1)
module = ".".join(path)
mod = importlib.import_module(module)
return getattr(mod, to_load)


version_getters = {
'setup-cfg': lambda path: get_setup_version(None, path),
'conda': conda_recipe_version,
'getattr': import_and_get,
}

default_args = {
Expand Down
2 changes: 1 addition & 1 deletion devtools/conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package:
name: autorelease
# add ".dev0" for unreleased versions
version: "0.3.2"
version: "0.4.0"

source:
path: ../../
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pyyaml
gitpython
requests
future
pathlib2
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = autorelease
version = 0.3.2
version = 0.4.0
# version should end in .dev0 if this isn't to be released
short_description = Tools to keep the release process clean.
description = Tools to keep the release process clean.
Expand Down Expand Up @@ -28,6 +28,7 @@ classifiers =
Topic :: Software Development :: Testing

[options]
python_requires = >=3.7
install_requires =
packaging
pyyaml
Expand Down

0 comments on commit 7d07246

Please sign in to comment.