]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Publish workflow (#913)
authorTom Christie <tom@tomchristie.com>
Thu, 30 Apr 2020 14:22:54 +0000 (15:22 +0100)
committerGitHub <noreply@github.com>
Thu, 30 Apr 2020 14:22:54 +0000 (15:22 +0100)
* Publish workflow

* Set PYTHONPATH to allow auto docs to import package

* Seperate install, build, publish steps

.github/workflows/publish.yml [new file with mode: 0644]
.github/workflows/test-suite.yml
scripts/build [new file with mode: 0755]
scripts/publish

diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644 (file)
index 0000000..a41fd2b
--- /dev/null
@@ -0,0 +1,27 @@
+---
+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: "Install dependencies"
+        run: "scripts/install"
+      - name: "Build package & docs"
+        run: "scripts/build"
+      - name: "Publish to PyPI & deploy docs"
+        run: "scripts/publish"
+        env:
+          TWINE_USERNAME: __token__
+          TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
index e29dcaffc2e965b68979ae997ad3dadc1cc09cf8..1d646694c7b194796b093ab27d6ae3816626b089 100644 (file)
@@ -2,8 +2,6 @@
 name: Test Suite
 
 on:
-  push:
-    branches: ["master"]
   pull_request:
     branches: ["master"]
 
diff --git a/scripts/build b/scripts/build
new file mode 100755 (executable)
index 0000000..1c47d2c
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh -e
+
+if [ -d 'venv' ] ; then
+    PREFIX="venv/bin/"
+else
+    PREFIX=""
+fi
+
+set -x
+
+${PREFIX}python setup.py sdist bdist_wheel
+${PREFIX}twine check dist/*
+${PREFIX}mkdocs build
index cbbda3324ac6b60d54ec6b4252aba51c8cec286f..9b520e2877e228d5dadf76fdac318f964426f11a 100755 (executable)
@@ -1,41 +1,26 @@
 #!/bin/sh -e
 
-export PACKAGE="httpx"
-export VERSION=`cat ${PACKAGE}/__version__.py | grep __version__ | sed "s/__version__ = //" | sed "s/'//g"`
-export PREFIX=""
+VERSION_FILE="httpx/__init__.py"
+
 if [ -d 'venv' ] ; then
-    export PREFIX="venv/bin/"
+    PREFIX="venv/bin/"
+else
+    PREFIX=""
 fi
 
-scripts/clean
-
-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
+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 ! ${PREFIX}pip show wheel &>/dev/null ; then
-    echo "Unable to find the 'wheel' command."
-    echo "Install from PyPI, using '${PREFIX}pip install wheel'."
-    exit 1
-fi
+  VERSION=`grep __version__ ${VERSION_FILE} | grep -o '[0-9][^"]*'`
 
-if ! command -v "${PREFIX}mkdocs" &>/dev/null ; then
-    echo "Unable to find the 'mkdocs' command."
-    echo "Install from PyPI, using '${PREFIX}pip install mkdocs'."
+  if [ "refs/tags/${VERSION}" != "${GITHUB_REF}" ] ; then
+    echo "GitHub Ref '${GITHUB_REF}' did not match package version '${VERSION}'"
     exit 1
+  fi
 fi
 
-find ${PACKAGE} -type f -name "*.py[co]" -delete
-find ${PACKAGE} -type d -name __pycache__ -delete
+set -x
 
-${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