Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish to Pypi | |
on: | |
release: | |
# job will automatically run after a new "release" is create on github. | |
types: [published] | |
jobs: | |
publish_fastapi_websocket_rpc: | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/permit | |
permissions: | |
id-token: write | |
contents: write # 'write' access to repository contents | |
pull-requests: write # 'write' access to pull requests | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Python setup | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11.8' | |
- name: Bump version and build package | |
run: | | |
# Get version tag and remove 'v' prefix | |
version_tag=${{ github.event.release.tag_name }} | |
version_tag=${version_tag#v} | |
# Update version in setup.py | |
sed -i "s/version=\"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\"/version=\"$version_tag\"/" setup.py | |
# Print version for verification | |
echo "Version being published: $version_tag" | |
cat setup.py | grep version= | |
- name: Build Python package | |
run: | | |
pip install wheel | |
python setup.py sdist bdist_wheel | |
# Publish package distributions to PyPI | |
- name: Publish package distributions to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_TOKEN }} | |
# For Test only ! | |
# password: ${{ secrets.TEST_PYPI_TOKEN }} | |
# repository-url: https://test.pypi.org/legacy/ | |