Skip to content

Commit

Permalink
Merge pull request #5 from mbeacom/enable-auto-release
Browse files Browse the repository at this point in the history
Enable automatic release to PyPi on tag
  • Loading branch information
hackersifu authored Feb 25, 2022
2 parents 6e35e4a + 95b78c4 commit 1db3479
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
on:
push:
tags:
- '*'

name: Create & Publish Package

jobs:
publish:
name: Create & Publish Package
runs-on: 'ubuntu-latest'
steps:
- name: Checkout Source
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.7'

- name: Cache Poetry
id: cache-poetry
uses: actions/cache@v2
with:
path: ~/.poetry
key: poetry

- name: Install Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py -O
python install-poetry.py --preview
- name: Add Poetry to $PATH
run: echo "$HOME/.poetry/bin" >> $GITHUB_PATH

- name: Add versioning plugin
run: poetry plugin add poetry-version-plugin

- name: Poetry Version
run: poetry --version

- name: Add version to environment vars
run: echo "MODULE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Check if source version is up-to-date
run: |
TAG=$(git describe HEAD --tags --abbrev=0)
echo Current Tag: $TAG -- Current Module Version: $MODULE_VERSION
if [[ "$TAG" != "$MODULE_VERSION" ]]; then exit 1; fi
- name: Check pyproject.toml validity
run: poetry check --no-interaction

- name: Cache Dependencies
id: cache-deps
uses: actions/cache@v2
with:
path: ${{github.workspace}}/.venv
key: poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: poetry-

- name: Install deps
if: steps.cache-deps.cache-hit != 'true'
run: |
poetry config virtualenvs.in-project true
poetry install --no-interaction
- name: Build Package
run: poetry build

- name: Publish to PyPi
run: poetry publish -u __token__ -p $PYPI_TOKEN
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

0 comments on commit 1db3479

Please sign in to comment.