1
+ name : Build and publish to Pypi
2
+ on :
3
+ release :
4
+ # job will automatically run after a new "release" is create on github.
5
+ types : [published]
6
+
7
+ jobs :
8
+ publish_fastapi_websocket_rpc :
9
+ runs-on : ubuntu-latest
10
+ environment :
11
+ name : pypi
12
+ url : https://pypi.org/p/permit
13
+ permissions :
14
+ id-token : write
15
+ contents : write # 'write' access to repository contents
16
+ pull-requests : write # 'write' access to pull requests
17
+ steps :
18
+ - name : Checkout
19
+ uses : actions/checkout@v4
20
+
21
+ - name : Python setup
22
+ uses : actions/setup-python@v5
23
+ with :
24
+ python-version : ' 3.11.8'
25
+
26
+ - name : Bump version and build package
27
+ run : |
28
+ # Get version tag and remove 'v' prefix
29
+ version_tag=${{ github.event.release.tag_name }}
30
+ version_tag=${version_tag#v}
31
+
32
+ # Update version in setup.py
33
+ sed -i "s/version=\"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\"/version=\"$version_tag\"/" setup.py
34
+
35
+ # Print version for verification
36
+ echo "Version being published: $version_tag"
37
+ cat setup.py | grep version=
38
+
39
+ - name : Build Python package
40
+ run : |
41
+ pip install wheel
42
+ python setup.py sdist bdist_wheel
43
+
44
+ # Publish package distributions to PyPI
45
+ - name : Publish package distributions to PyPI
46
+ uses : pypa/gh-action-pypi-publish@release/v1
47
+ with :
48
+ password : ${{ secrets.PYPI_TOKEN }}
49
+ # For Test only !
50
+ # password: ${{ secrets.TEST_PYPI_TOKEN }}
51
+ # repository-url: https://test.pypi.org/legacy/
52
+
0 commit comments