Skip to content

v0.4.4: Also ignore D102 for tests #32

v0.4.4: Also ignore D102 for tests

v0.4.4: Also ignore D102 for tests #32

name: Publish Package
on:
release:
types: [released]
env:
# Versions are also listed in PR.yml
POETRY_VERSION: 1.2.2
PYTHON_VERSION: 3.9 # Use latest
jobs:
publish_package:
name: Publish Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.release.target_commitish }} # This is the branch the release was created from. Normally main, but can be a dev branch
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: Gr1N/setup-poetry@v8
with:
poetry-version: ${{ env.POETRY_VERSION }}
# @TODO: This is a workaround for there not being a way to check the lock file
# See: https://github.com/python-poetry/poetry/issues/453
- name: Check for lock changes
run: |
poetry lock --check
- uses: actions/cache@v2
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
- name: Install the Package
run: poetry install
- name: Lint the Code
run: poetry run ni-python-styleguide lint
- name: Run tests
run: poetry run pytest -v
# If the version is 0.1.0-alpha.0, this will set the version to 0.1.0
- name: Promote package version to release
run: |
poetry version patch
- name: Build Python package and publish to PyPI
if: ${{ github.event.release.target_commitish == 'main' }}
run: |
poetry publish --build --username __token__ --password ${{ secrets.PYPI_TOKEN}}
- name: Bump poetry version to next alpha version
run: |
poetry version prepatch
- name: Commit files
if: ${{ github.event.release.target_commitish == 'main' }}
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git pull --tags -f
git commit -m "Bump package version" -a
- name: Push changes
if: ${{ github.event.release.target_commitish == 'main' }}
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.ADMIN_PAT }}
branch: ${{ github.event.release.target_commitish }}
unprotect_reviews: true