Skip to content

Commit 4524fa0

Browse files
fix: release to PyPI from semantic release outputs
1 parent 69633be commit 4524fa0

1 file changed

Lines changed: 27 additions & 7 deletions

File tree

.github/workflows/publish.yml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
pull_request:
77
branches: [main]
88

9+
env:
10+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
11+
912
permissions:
1013
contents: write
1114
id-token: write
@@ -51,8 +54,12 @@ jobs:
5154
- name: Checkout repository
5255
uses: actions/checkout@v4
5356
with:
57+
ref: ${{ github.ref_name }}
5458
fetch-depth: 0
5559

60+
- name: Force branch to workflow SHA
61+
run: git reset --hard ${{ github.sha }}
62+
5663
- name: Set up Python
5764
uses: actions/setup-python@v5
5865
with:
@@ -65,10 +72,23 @@ jobs:
6572
pip install -e ".[dev]"
6673
pip install build
6774
68-
- name: Publish release
69-
env:
70-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71-
TWINE_USERNAME: __token__
72-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
73-
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
74-
run: python -m semantic_release publish
75+
- name: Create semantic release
76+
id: release
77+
uses: python-semantic-release/python-semantic-release@v10.5.3
78+
with:
79+
github_token: ${{ secrets.GITHUB_TOKEN }}
80+
git_committer_name: github-actions
81+
git_committer_email: actions@users.noreply.github.com
82+
83+
- name: Upload GitHub release assets
84+
uses: python-semantic-release/publish-action@v10.5.3
85+
if: steps.release.outputs.released == 'true'
86+
with:
87+
github_token: ${{ secrets.GITHUB_TOKEN }}
88+
tag: ${{ steps.release.outputs.tag }}
89+
90+
- name: Publish to PyPI
91+
uses: pypa/gh-action-pypi-publish@release/v1
92+
if: steps.release.outputs.released == 'true'
93+
with:
94+
packages-dir: dist

0 commit comments

Comments
 (0)