Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable automatic release to PyPi on tag #5

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 }}