@@ -121,26 +121,42 @@ jobs:
121121 py.test --cov-report= --cov=logwrap test
122122 coverage report -m --fail-under 85
123123
124+ Build :
125+ needs : [ Test ]
126+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
127+ runs-on : ubuntu-latest
128+ steps :
129+ - uses : actions/checkout@v3
130+ - name : Set up Python
131+ uses : actions/setup-python@v4
132+ with :
133+ python-version : ' 3.x'
134+ - name : Install dependencies
135+ run : |
136+ python -m pip install --upgrade pip
137+ pip install --upgrade twine build
138+ - name : Build package
139+ run : |
140+ python -m build
141+ - uses : actions/upload-artifact@v3
142+ with :
143+ path : dist/*
144+
124145 Deploy :
125- needs : [Test ]
146+ needs : [Build ]
126147 if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
127148 runs-on : ubuntu-latest
149+ environment :
150+ name : pypi
151+ url : https://pypi.org/p/logwrap
152+ permissions :
153+ id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
128154 steps :
129- - uses : actions/checkout@v3
130- - name : Set up Python
131- uses : actions/setup-python@v4
155+ - uses : actions/download-artifact@v3
132156 with :
133- python-version : ' 3.x'
134- - name : Install dependencies
135- run : |
136- python -m pip install --upgrade pip
137- pip install --upgrade twine build
138- - name : Build package
139- run : |
140- python -m build
141- - name : Deploy
142- env :
143- TWINE_USERNAME : ${{ secrets.PYPI_USERNAME }}
144- TWINE_PASSWORD : ${{ secrets.PYPI_PASSWORD }}
145- run : |
146- twine upload --skip-existing dist/*
157+ # unpacks default artifact into dist/
158+ # if `name: artifact` is omitted, the action will create extra parent dir
159+ name : artifact
160+ path : dist
161+ - name : Publish package distributions to PyPI
162+ uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments