Skip to content

Merge pull request #95 from eurunuela/linting #66

Merge pull request #95 from eurunuela/linting

Merge pull request #95 from eurunuela/linting #66

name: Publish to PyPI
on:
release:
types: [published]
push:
branches:
- main
jobs:
build-publish:
runs-on: ubuntu-latest
# This ensures that the publish action only runs in the main repository
# rather than forks
# Environment is encouraged so adding
environment: release
if: github.repository_owner == 'Paradigm-Free-Mapping'
permissions:
id-token: write # this permission is mandatory for pypi publishing
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# This fetch element is only important if you are use SCM based
# versioning (that looks at git tags to gather the version)
fetch-depth: 100
# Need the tags so that setuptools-scm can form a valid version number
- name: Fetch git tags
run: git fetch origin 'refs/tags/*:refs/tags/*'
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install Hatch
run: |
pipx install hatch
pip list
- name: Build package using Hatch
run: |
hatch build
echo ""
echo "Generated files:"
ls -lh dist/
- name: Publish package on test PyPI on merge in main branch
# Test push to test pypi on merge to main
if: github.event_name == 'push'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
# Allow existing releases on test PyPI without errors.
# NOT TO BE USED in PyPI!
skip-existing: true
- name: Publish package to PyPI
# Only publish to real PyPI on release
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1