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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## UNRELEASED

- Fixes issue with scaffold code that import of config did not work. Adds testing of imports to test suite. (Issue [#370](https://github.com/drivendataorg/cookiecutter-data-science/issues/370))
- Create automated release mechanism (Issue [#317](https://github.com/drivendataorg/cookiecutter-data-science/issues/317)) and pin template version to installed release (Issue [#389](https://github.com/drivendataorg/cookiecutter-data-science/issues/389))

## v2.0.0 (2024-05-22)

Expand Down
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 use the _project template_ version that corresponds to the _installed `ccds` package_ version (e.g., if you have installed `ccds` v2.0.1, you'll use the v2.0.1 version of the project template by default). To use a specific version of the project template, use the `-c/--checkout` flag to provide the branch (or tag or commit hash) of the version you'd like to use. For example to use the project template from the `master` branch:

```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
11 changes: 11 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Information for releases and versioning of ccds

## Background

The release of [ccds v2](https://drivendata.co/blog/ccds-v2) introduced the `ccds` utility and the concept of versioning to cookiecutter data science. Prior to this release, cookiecutter-data-science only provided a project template, which the generic [cookiecutter](https://github.com/cookiecutter/cookiecutter) utility could use to instantiate a project. Branches and forks could be used in the usual way to get different versions of the template.

To give the utility and the template a bit more stability, PR [#336](https://github.com/drivendataorg/cookiecutter-data-science/pull/336) created automated release mechanics for publishing new releases and, by default, pinned the template used by the `ccds` utility to the installed version.

## Issuing a new release

`ccds` uses [semantic versioning](https://semver.org/). When issuing a new release, **ensure that your release version tag has the format `vMAJOR.MINOR.PATCH`. The `v` prefix is important because the utility will look for the tag with that name to download by default.
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__
7 changes: 7 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,11 @@ def _main(*args, **kwargs):
f.params[1].default = (
"https://github.com/drivendataorg/cookiecutter-data-science"
)
# Find the "checkout" option in the cookiecutter cli (currently the fifth)
# Per #389, set this to the currently released version by default
param_names = [p.name for p in f.params]
checkout_index = param_names.index("checkout")
f.params[checkout_index].default = f"v{__version__}"
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

chrisjkuch marked this conversation as resolved.
Show resolved Hide resolved
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