Skip to content

Commit

Permalink
Add publish workflow (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
florimondmanca authored Jun 4, 2020
1 parent 29df422 commit c81cd51
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 3 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Publish

on:
push:
tags:
- '*'

jobs:
publish:
name: "Publish to PyPI"
runs-on: "ubuntu-18.04"

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
with:
python-version: 3.8
- name: "Install dependencies"
run: scripts/install
- name: "Build package artifacts"
run: scripts/build
- name: "Publish to PyPI"
run: scripts/publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
30 changes: 27 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
# Contributing guidelines

To install development dependencies, run:
Thank you for being interested in contributing to this project! Here's how to get started.

## Setup

To start developing on this project, create a fork of this repository on GitHub, then clone your fork on your machine:

```bash
git clone https://github.com/<USERNAME>/mkdocs-click
```

You can now install development dependencies using:

```bash
cd mkdocs-click
scripts/install
```

Once this is done, you should be able to run the test suite:
## Testing and linting

Once dependencies are installed, you can run the test suite using:

```bash
scripts/test
```

Code auto formatting can be run with:
You can run code auto-formatting using:

```bash
scripts/format
Expand All @@ -23,3 +36,14 @@ To run style checks, use:
```bash
scripts/style
```

## Releasing

_This section is for maintainers._

Before releasing a new version, create a pull request with:

- An update to the changelog.
- A version bump: see `__version__.py`.

Merge the release PR, then create a release on GitHub. A tag will be created which will trigger a GitHub action to publish the new release to PyPI.
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
-e .

# Packaging
twine
wheel

# Linters
black
flake8
Expand Down
10 changes: 10 additions & 0 deletions scripts/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/sh -e

BIN="venv/bin/"

set -x

${BIN}python setup.py sdist bdist_wheel
${BIN}twine check dist/*

rm -r build
17 changes: 17 additions & 0 deletions scripts/publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#! /bin/sh -e

PACKAGE="mkdocs_click"
BIN="venv/bin/"

if [ "$GITHUB_ACTIONS" ]; then
VERSION=`${BIN}python -c "import $PACKAGE; print($PACKAGE.__version__)"`

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

set -x

${BIN}twine upload dist/*

0 comments on commit c81cd51

Please sign in to comment.