1- name : Build and upload to PyPI
1+ name : Publish IBM_DB_SA Package
22
3- # Build on every workflow_dispatch, branch push, tag push, and pull request change
43on :
54 workflow_dispatch :
65 pull_request :
1110 tags :
1211 - ' v*' # Push events to matching v*, i.e. v1.0, v20.15.10
1312
14- jobs :
15- deploy :
13+ permissions :
14+ contents : read
15+ id-token : write # Required for trusted publishing to PyPI via OIDC
1616
17+ jobs :
18+ publish-pypi :
19+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
1720 runs-on : ubuntu-latest
21+ environment : pypi # Environment where PYPI_API_TOKEN secret is stored
1822
1923 steps :
20- - uses : actions/checkout@v4
21- - name : Set up Python
22- uses : actions/setup-python@v5
23- with :
24- python-version : ' 3.x'
25- - name : Install dependencies
26- run : |
27- python -m pip install --upgrade pip
28- pip install build
29- - name : Build package
30- run : |
31- python -m build
32- - name : Publish distribution to PyPI
33- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
34- uses : pypa/gh-action-pypi-publish@release/v1
35-
36- permissions :
37- # IMPORTANT: this permission is mandatory for trusted publishing
38- id-token : write
39- contents : write # Added permission for GitHub Actions to push tags
24+ - name : Checkout code
25+ uses : actions/checkout@v4
26+
27+ - name : Set up Python
28+ uses : actions/setup-python@v5
29+ with :
30+ python-version : ' 3.x'
31+
32+ - name : Install build dependencies
33+ run : |
34+ python -m pip install --upgrade pip
35+ pip install build
36+
37+ - name : Build package
38+ run : python -m build
39+
40+ - name : Publish to PyPI with trusted publishing (OIDC)
41+ uses : pypa/gh-action-pypi-publish@v1.5.0
42+ with :
43+ # Use GitHub OIDC token to authenticate instead of password
44+ # The action supports OIDC automatically when password is empty
45+ # so leave password empty and it will use OIDC.
46+ user : __token__
47+ password : ${{ secrets.PYPI_API_TOKEN }}
48+ packages_dir : dist
0 commit comments