Skip to content

Update python-publish.yml #123

Update python-publish.yml

Update python-publish.yml #123

Workflow file for this run

name: Build and upload to PyPI
# Build on every branch push, tag push, and pull request change:
#on: [push, pull_request]
# Alternatively, to publish when a (published) GitHub Release is created, use the following:
on:
push:
pull_request:
release:
types:
- published
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [tag_version]
strategy:
matrix:
os: [ubuntu-22.04]
steps:
- uses: actions/checkout@v3
- name: Set version from tag
run: |
echo "version is: ${{ needs.tag_version.outputs.sem_ver }}"
sed -i "s/%VERSION%/${{ needs.tag_version.outputs.sem_ver }}/" pysysdc/__version__.py stdeb.cfg
- name: Build wheels
uses: pypa/cibuildwheel@v2.11.4
- uses: actions/upload-artifact@v4
with:
name: wheels
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
needs: [tag_version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build sdist
run: |
echo "version is: ${{ needs.tag_version.outputs.sem_ver }}"
sed -i "s/%VERSION%/${{ needs.tag_version.outputs.sem_ver }}/" pysysdc/__version__.py stdeb.cfg
pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
tag_version:
runs-on: ubuntu-latest
outputs:
sem_ver: ${{ steps.ver_tag.outputs.new_tag }}
name: Bump version
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Bump version and push tag
id: ver_tag
uses: anothrNick/github-tag-action@1.55.0 # Don't use @master unless you're happy to test the latest version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
TAG_CONTEXT: branch
INITIAL_VERSION: 'v2.0.0'
VERBOSE: false
- name: print_version
run: echo "fetched tag version ${{ steps.ver_tag.outputs.new_tag }}"
upload_pypi:
needs: [build_wheels, build_sdist, tag_version]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}