Skip to content

Commit 579ee65

Browse files
committed
added publish workflow
1 parent 439f4fd commit 579ee65

File tree

6 files changed

+88
-1
lines changed

6 files changed

+88
-1
lines changed

.github/workflows/publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
publish:
10+
name: "Publish release"
11+
runs-on: "ubuntu-latest"
12+
13+
environment:
14+
name: deploy
15+
16+
steps:
17+
- uses: "actions/checkout@v2"
18+
- uses: "actions/setup-python@v2"
19+
with:
20+
python-version: 3.7
21+
- name: "Install dependencies"
22+
run: "scripts/install"
23+
- name: "Build package & docs"
24+
run: "scripts/build"
25+
- name: "Publish to PyPI & deploy docs"
26+
run: "scripts/publish"
27+
env:
28+
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
29+
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}

compressor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# following PEP 386
2-
__version__ = "2.3.4"
2+
__version__ = "2.3.5"

requirements/publish.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
twine==4.0.0
2+
wheel==0.37.1

scripts/build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh -e
2+
3+
if [ -d 'venv' ] ; then
4+
PREFIX="venv/bin/"
5+
else
6+
PREFIX=""
7+
fi
8+
9+
set -x
10+
11+
${PREFIX}python setup.py sdist bdist_wheel
12+
${PREFIX}twine check dist/*

scripts/publish-install.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh -e
2+
3+
# Use the Python executable provided from the `-p` option, or a default.
4+
[ "$1" = "-p" ] && PYTHON=$2 || PYTHON="python3"
5+
6+
REQUIREMENTS="requirements/publish.txt"
7+
VENV="venv"
8+
9+
set -x
10+
11+
if [ -z "$GITHUB_ACTIONS" ]; then
12+
"$PYTHON" -m venv "$VENV"
13+
PIP="$VENV/bin/pip"
14+
else
15+
PIP="pip"
16+
fi
17+
18+
"$PIP" install -r "$REQUIREMENTS"
19+
"$PIP" install -e .

scripts/publish.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh -e
2+
3+
VERSION_FILE="compressor/__init__.py"
4+
5+
if [ -d 'venv' ] ; then
6+
PREFIX="venv/bin/"
7+
else
8+
PREFIX=""
9+
fi
10+
11+
if [ ! -z "$GITHUB_ACTIONS" ]; then
12+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
13+
git config --local user.name "GitHub Action"
14+
15+
VERSION=`grep __version__ ${VERSION_FILE} | grep -o '[0-9][^"]*'`
16+
17+
if [ "refs/tags/${VERSION}" != "${GITHUB_REF}" ] ; then
18+
echo "GitHub Ref '${GITHUB_REF}' did not match package version '${VERSION}'"
19+
exit 1
20+
fi
21+
fi
22+
23+
set -x
24+
25+
${PREFIX}twine upload dist/*

0 commit comments

Comments
 (0)