Skip to content

Commit

Permalink
added publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
eadwinCode committed Jun 18, 2022
1 parent 439f4fd commit 579ee65
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish

on:
push:
tags:
- '*'

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

environment:
name: deploy

steps:
- uses: "actions/checkout@v2"
- uses: "actions/setup-python@v2"
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: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
2 changes: 1 addition & 1 deletion compressor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# following PEP 386
__version__ = "2.3.4"
__version__ = "2.3.5"
2 changes: 2 additions & 0 deletions requirements/publish.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
twine==4.0.0
wheel==0.37.1
12 changes: 12 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/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/*
19 changes: 19 additions & 0 deletions scripts/publish-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh -e

# Use the Python executable provided from the `-p` option, or a default.
[ "$1" = "-p" ] && PYTHON=$2 || PYTHON="python3"

REQUIREMENTS="requirements/publish.txt"
VENV="venv"

set -x

if [ -z "$GITHUB_ACTIONS" ]; then
"$PYTHON" -m venv "$VENV"
PIP="$VENV/bin/pip"
else
PIP="pip"
fi

"$PIP" install -r "$REQUIREMENTS"
"$PIP" install -e .
25 changes: 25 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh -e

VERSION_FILE="compressor/__init__.py"

if [ -d 'venv' ] ; then
PREFIX="venv/bin/"
else
PREFIX=""
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"

VERSION=`grep __version__ ${VERSION_FILE} | grep -o '[0-9][^"]*'`

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

set -x

${PREFIX}twine upload dist/*

0 comments on commit 579ee65

Please sign in to comment.