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

Switch to automatic PyPI uploads via CI #166

Merged
merged 1 commit into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


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

on:
push:
tags:
- "*"

jobs:
publish:
name: Publish release
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: scripts/install
- name: Build package and docs
run: scripts/build
- name: Publish to PyPI & deploy docs
run: scripts/publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ To make a new release:
- Create a PR with the following:
- Bump the package version by editing `__version__.py`.
- Update the changelog with any relevant PRs merged since the last version: bug fixes, new features, changes, deprecations, removals.
- Merge the PR.
- Run `$ scripts/build` then `$ scripts/publish` on `master`.
- Tag the commit and push the tag to the remote.
- Get the PR reviewed and merged.
- Once the release PR is reviewed and merged, create a new release on the GitHub UI, including:
- Tag version, like `0.11.0`.
- Release title, `Version 0.11.0`.
- Description copied from the changelog.
- Once created, the release tag will trigger a 'publish' job on CI, automatically pushing the new version to PyPI.
17 changes: 14 additions & 3 deletions scripts/publish
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@ if [ -d 'venv' ] ; then
export PREFIX="venv/bin/"
fi

find src -type f -name "*.py[co]" -delete
find src -type d -name __pycache__ -delete
if [ ! -z "$GITHUB_ACTIONS" ]; then
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "GitHub Action"

VERSION=`grep __version__ ${VERSION_FILE} | grep -o '[0-9][^"]*'`

if [ "refs/tags/${VERSION}" != "${GITHUB_REF}" ] ; then
echo "GitHub Ref '${GITHUB_REF}' did not match package version '${VERSION}'"
exit 1
fi
fi

set -x

${PREFIX}twine upload dist/*
${PREFIX}mkdocs gh-deploy
${PREFIX}mkdocs gh-deploy --force