diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4e2db68 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +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/ + \ No newline at end of file