Skip to content

Commit

Permalink
build: setup release-please to automate releases (#243)
Browse files Browse the repository at this point in the history
* build: setup release-please to automate releases

* whitespace

* add setup.cfg, as suggested by release-please docs
  • Loading branch information
tswast committed Apr 29, 2021
1 parent e0b2be0 commit 3575827
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 55 deletions.
3 changes: 3 additions & 0 deletions .github/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
primaryBranch: develop
releaseType: python
handleGHRelease: true
27 changes: 27 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,30 @@ cd professional-services-data-validator/
python -m pip install --upgrade pip
python -m pip install .
```

## Conventional Commits

This project uses [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) to manage the
CHANGELOG and releases.

Allowed commit prefixes are defined in the [release-please source
code](https://github.com/googleapis/release-please/blob/master/src/releasers/python.ts):

### User-facing commits

- `feat: ` section: 'Features'
- `fix: ` section: 'Bug Fixes'
- `perf: ` section: 'Performance Improvements'
- `deps: ` section: 'Dependencies'
- `revert: ` section: 'Reverts'
- `docs: ` section: 'Documentation'

### Hidden commits (not shown in CHANGELOG)

- `style: ` section: 'Styles', hidden: true
- `chore: ` section: 'Miscellaneous Chores', hidden: true
- `refactor: ` section: 'Code Refactoring', hidden: true
- `test: ` section: 'Tests', hidden: true
- `build: ` section: 'Build System', hidden: true
- `ci: ` section: 'Continuous Integration', hidden: true
91 changes: 36 additions & 55 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,37 @@ First, prepare a development environment. Follow the instructions in the
install the package locally, and add any dependencies needed for testing such
as nox or pytest.

In order to build packages for distribution, also install `setuptools` and
`wheel` into your development virtual environment.
1. Create PyPI (https://pypi.org/) and PyPI Test (https://test.pypi.org/) accounts. Example: https://pypi.org/user/TimSwast/

```
pip install setuptools wheel
```
2. Configure PyPI with a `.pypirc` file: https://packaging.python.org/specifications/pypirc/#using-a-pypi-token

## Prepare a release

- Update [CHANGELOG.md](CHANGELOG.md) based on git commit history since last
release.

Template (include only those sections that apply):
3. Have a remote named "upstream" pointing at this copy on GitHub.

```
### Features
```
git remote add upstream [email protected]:GoogleCloudPlatform/professional-services-data-validator.git
```

### Bug Fixes
4. Install `setuptools`, [twine](https://twine.readthedocs.io/en/latest/) CLI
for PyPI, and `wheel` into your development virtual environment.

### Dependencies
```
pip install setuptools twine wheel
```

### Documentation
## Prepare a release

### Internal / Testing Changes
```
- Update the version string in [setup.py](setup.py).
- Send a pull request with your changes.
- Review and merge PR from `release-please`. If anything needs adjusting,
update the files in the PR. Check that it:
- Updates version string in `setup.py`.
- Includes all expected changes in `CHANGELOG.md`.

## Build a package

- After the PR is merged, checkout the main `develop` branch.

```
git fetch upstream develop
git checkout develop
git rebase -i upstream/develop
git fetch upstream --tags
git checkout vA.B.C
```

- Remove any temporary files leftover from previous builds.
Expand Down Expand Up @@ -75,42 +70,28 @@ pip install setuptools wheel

## Publish the package

- Tag the release.
- [Optional] Upload to test PyPI. See [documentation for
TestPyPI](https://packaging.python.org/guides/using-testpypi/)

```
git tag -a x.x.x -m 'Version x.x.x'
```
```
twine upload --repository testpypi dist/*
```

- Push the tag to GitHub.
- [Optional] Try out test PyPI package

```
git push upstream develop --tags
```
```
pip install --upgrade \
--index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
google-pso-data-validator
```

- Upload to PyPI

```
twine upload dist/*
```

- Find the tag in the [GitHub
releases](https://github.com/GoogleCloudPlatform/professional-services-data-validator/releases).
- Copy the release notes there.
- Upload both files from the `dist/` directory.

- Upload the `.whl` wheel file, README, and CHANGELOG to [Google
Drive](https://drive.google.com/corp/drive/folders/1C387pJKyqOCTN0I7sIm0SP6pfHu0PrLG).

- Release Version to GCS

```
export PACKAGE_VERSION=X.X.X
gsutil cp README.md CHANGELOG.md dist/google_pso_data_validator-${PACKAGE_VERSION}-py3-none-any.whl dist/google-pso-data-validator-${PACKAGE_VERSION}.tar.gz gs://professional-services-data-validator/releases/${PACKAGE_VERSION}/
gsutil -m acl ch -u AllUsers:R gs://professional-services-data-validator/releases/${PACKAGE_VERSION}/**
```

- Release Latest to GCS

```
export PACKAGE_VERSION=X.X.X
gsutil cp README.md CHANGELOG.md gs://professional-services-data-validator/releases/latest/
gsutil cp dist/google_pso_data_validator-${PACKAGE_VERSION}-py3-none-any.whl gs://professional-services-data-validator/releases/latest/google_pso_data_validator-latest-py3-none-any.whl
gsutil cp dist/google-pso-data-validator-${PACKAGE_VERSION}.tar.gz gs://professional-services-data-validator/releases/latest/google-pso-data-validator-latest.tar.gz
gsutil -m acl ch -u AllUsers:R gs://professional-services-data-validator/releases/latest/**
```
18 changes: 18 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
#
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[bdist_wheel]
universal = 1

0 comments on commit 3575827

Please sign in to comment.