Skip to content

Commit b0aa6ac

Browse files
Publish workflow (#62)
* Publish workflow * Set PYTHONPATH to allow auto docs to import package
1 parent ac1d91f commit b0aa6ac

3 files changed

Lines changed: 39 additions & 23 deletions

File tree

.github/workflows/publish.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Publish
3+
4+
on:
5+
push:
6+
tags:
7+
- '*'
8+
9+
jobs:
10+
publish:
11+
name: "Publish release"
12+
runs-on: "ubuntu-latest"
13+
14+
steps:
15+
- uses: "actions/checkout@v2"
16+
- uses: "actions/setup-python@v1"
17+
with:
18+
python-version: 3.7
19+
- name: "Publish"
20+
run: "scripts/publish"
21+
env:
22+
TWINE_USERNAME: __token__
23+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

.github/workflows/test-suite.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
name: Test Suite
33

44
on:
5-
push:
6-
branches: ["master"]
75
pull_request:
86
branches: ["master"]
97

scripts/publish

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
11
#!/bin/sh -e
22

3-
export VERSION=`cat httpcore/__init__.py | grep __version__ | sed "s/__version__ = //" | sed "s/'//g"`
4-
export PREFIX=""
3+
VERSION_FILE="httpcore/__init__.py"
4+
PYTHONPATH=.
5+
56
if [ -d 'venv' ] ; then
6-
export PREFIX="venv/bin/"
7+
PREFIX="venv/bin/"
8+
else
9+
PREFIX=""
710
fi
811

9-
scripts/clean
12+
if [ ! -z "$GITHUB_ACTIONS" ]; then
13+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
14+
git config --local user.name "GitHub Action"
1015

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

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

23-
find httpcore -type f -name "*.py[co]" -delete
24-
find httpcore -type d -name __pycache__ -delete
24+
set -x
2525

26+
${PREFIX}pip install twine wheel mkdocs mkdocs-material mkautodoc
2627
${PREFIX}python setup.py sdist bdist_wheel
2728
${PREFIX}twine upload dist/*
28-
${PREFIX}mkdocs gh-deploy
29-
30-
echo "You probably want to also tag the version now:"
31-
echo "git tag -a ${VERSION} -m 'version ${VERSION}'"
32-
echo "git push --tags"
33-
34-
scripts/clean
29+
${PREFIX}mkdocs gh-deploy --force

0 commit comments

Comments
 (0)