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 publish workflow #921

Merged
merged 1 commit into from Apr 29, 2020
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
23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
@@ -0,0 +1,23 @@
---
name: Publish

on:
push:
tags:
- '*'

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

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v1"
with:
python-version: 3.7
- name: "Publish"
run: "scripts/publish"
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
2 changes: 0 additions & 2 deletions .github/workflows/test-suite.yml
Expand Up @@ -2,8 +2,6 @@
name: Test Suite

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

Expand Down
36 changes: 15 additions & 21 deletions scripts/publish
@@ -1,34 +1,28 @@
#!/bin/sh -e

export VERSION=`cat starlette/__init__.py | grep __version__ | sed "s/__version__ = //" | sed "s/'//g"`
export PREFIX=""
VERSION_FILE="starlette/__init__.py"

if [ -d 'venv' ] ; then
export PREFIX="venv/bin/"
PREFIX="venv/bin/"
else
PREFIX=""
fi

scripts/clean
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"

if ! command -v "${PREFIX}twine" &>/dev/null ; then
echo "Unable to find the 'twine' command."
echo "Install from PyPI, using '${PREFIX}pip install twine'."
exit 1
fi
VERSION=`grep __version__ ${VERSION_FILE} | grep -o '[0-9][^"]*'`

if ! command -v "${PREFIX}wheel" &>/dev/null ; then
echo "Unable to find the 'wheel' command."
echo "Install from PyPI, using '${PREFIX}pip install wheel'."
if [ "refs/tags/${VERSION}" != "${GITHUB_REF}" ] ; then
echo "GitHub Ref '${GITHUB_REF}' did not match package version '${VERSION}'"
exit 1
fi
fi

find starlette -type f -name "*.py[co]" -delete
find starlette -type d -name __pycache__ -delete
set -x

${PREFIX}pip install twine wheel mkdocs mkdocs-material mkautodoc
${PREFIX}python setup.py sdist bdist_wheel
${PREFIX}twine upload dist/*
${PREFIX}mkdocs gh-deploy

echo "You probably want to also tag the version now:"
echo "git tag -a ${VERSION} -m 'version ${VERSION}'"
echo "git push --tags"

scripts/clean
${PREFIX}mkdocs gh-deploy --force