Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release GitHub actions #336

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: release

on:
release:
types:
- published

jobs:
build:
name: Build and publish new release
runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r dev-requirements.txt

- name: Check that versions match
id: version
run: |
echo "Release tag: [${{ github.event.release.tag_name }}]"
PACKAGE_VERSION=$(python -c "import ccds; print(ccds.__version__)")
echo "Package version: [$PACKAGE_VERSION]"
[ ${{ github.event.release.tag_name }} == "v$PACKAGE_VERSION" ] || { exit 1; }
echo "::set-output name=major_minor_version::v${PACKAGE_VERSION%.*}"

- name: Build package
run: |
make dist

- name: Publish to Test PyPI
uses: pypa/[email protected]
with:
user: ${{ secrets.PYPI_TEST_USERNAME }}
password: ${{ secrets.PYPI_TEST_PASSWORD }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

- name: Publish to Production PyPI
uses: pypa/[email protected]
with:
user: ${{ secrets.PYPI_PROD_USERNAME }}
password: ${{ secrets.PYPI_PROD_PASSWORD }}
skip_existing: false
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,31 @@ lint:
isort --check --profile black ccds hooks tests docs/scripts
black --check ccds hooks tests docs/scripts

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage 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 {} +

clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache

dist: clean ## builds source and wheel package
python -m build
ls -l dist


### DOCS

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ The directory structure of your new project will look something like this (depen
└── plots.py <- Code to create visualizations
```

## Using unreleased changes

By default, `ccds` will download the most recently _released_ version of the template. If there are any _unreleased_ changes to the template (or changes in a separate branch) that you want to incorporate, you can do so by checking out whatever branch you'd like to use (checkout `master` for the latest changes):

```bash
ccds -c master
```

## Using v1

If you want to use the old v1 project template, you need to have either the cookiecutter-data-science package or cookiecutter package installed. Then, use either command-line program with the `-c v1` option:
Expand Down
3 changes: 3 additions & 0 deletions ccds/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ccds.version import __version__

__version__
5 changes: 5 additions & 0 deletions ccds/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from cookiecutter import cli
from cookiecutter import main as api_main # noqa: F401 referenced by tests

from ccds.version import __version__


def default_ccds_main(f):
"""Set the default for the cookiecutter template argument to the CCDS template."""
Expand All @@ -31,6 +33,9 @@ def _main(*args, **kwargs):
f.params[1].default = (
"https://github.com/drivendataorg/cookiecutter-data-science"
)
# The fifth parameter is the "checkout" option in the cookiecutter cli
# Per #389, set this to the currently released version by default
f.params[4].default = __version__
pjbull marked this conversation as resolved.
Show resolved Hide resolved
return f(*args, **kwargs)

return _main
Expand Down
9 changes: 9 additions & 0 deletions ccds/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys

if sys.version_info[:2] >= (3, 8):
import importlib.metadata as importlib_metadata
else:
import importlib_metadata


__version__ = importlib_metadata.version("cookiecutter-data-science")
10 changes: 9 additions & 1 deletion docs/docs/all-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@
CCDS provides a number of choices that you can use to customize your project. The defaults work well for many projects, but lots of tooling choices are supported. Here are the options for tools that you can use:


<!-- configuration-table.py output -->
<!-- configuration-table.py output -->

## Checking out other branches / using unreleased changes to the template

By default, `ccds` will download the most recently _released_ version of the template. If there are any _unreleased_ changes to the template (or changes in a separate branch) that you want to incorporate, you can do so by checking out whatever branch you'd like to use (checkout `master` for the latest changes):

```bash
ccds -c master
```
Loading