Skip to content

Commit 2150f4c

Browse files
author
Artem Yerofieiev
committed
Fix GitHub workflow permissions for creating releases
1 parent 9b96960 commit 2150f4c

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

.github/workflows/python-publish.yml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
- 'setup.py' # Trigger on version changes in setup.py
88
workflow_dispatch: # Allow manual triggering
99

10+
# Add permissions section
11+
permissions:
12+
contents: write
13+
packages: write
14+
1015
jobs:
1116
build-and-release:
1217
runs-on: ubuntu-latest
@@ -36,6 +41,13 @@ jobs:
3641
3742
- name: Build package
3843
run: |
44+
# Create pyproject.toml to ensure build works even without one
45+
if [ ! -f pyproject.toml ]; then
46+
echo "Creating minimal pyproject.toml"
47+
echo "[build-system]" > pyproject.toml
48+
echo "requires = ['setuptools>=42', 'wheel']" >> pyproject.toml
49+
echo "build-backend = 'setuptools.build_meta'" >> pyproject.toml
50+
fi
3951
python -m build
4052
python setup.py sdist bdist_wheel
4153
@@ -49,28 +61,12 @@ jobs:
4961
path: dist/*.whl
5062
# The wheel will have the naming format: ttnn_trace_viewer-version-py3-none-any.whl
5163

52-
- name: Create Release
53-
id: create_release
54-
uses: actions/create-release@v1
55-
env:
56-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
- name: Create Release and Upload Assets
65+
uses: softprops/action-gh-release@v1
5766
with:
5867
tag_name: v${{ steps.get_version.outputs.version }}
59-
release_name: Release v${{ steps.get_version.outputs.version }}
68+
name: Release v${{ steps.get_version.outputs.version }}
6069
draft: false
6170
prerelease: false
62-
63-
- name: Upload Release Assets
64-
uses: softprops/action-gh-release@v1
65-
with:
66-
tag_name: v${{ steps.get_version.outputs.version }}
6771
files: dist/*.whl
68-
token: ${{ secrets.GITHUB_TOKEN }}
69-
70-
- name: Publish to PyPI
71-
if: github.ref == 'refs/heads/main'
72-
uses: pypa/gh-action-pypi-publish@release/v1
73-
with:
74-
user: __token__
75-
password: ${{ secrets.PYPI_API_TOKEN }}
76-
skip_existing: true
72+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)