-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add separate GH Action to publish to PyPI and GH releases.
Uses the "publish" environment to control access.
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Publish Package | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
concurrency: | ||
group: publish | ||
|
||
|
||
jobs: | ||
publish: | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
name: Upload release to Github Releases and PyPI | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
contents: write | ||
environment: publish | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.11" | ||
- name: Build package | ||
run: | | ||
python -m pip install twine build | ||
python -m build --wheel --sdist | ||
python -m twine check dist/* | ||
ls -la dist | ||
- name: Create Release and Upload | ||
id: create_release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh release create ${{ github.ref_name }} --repo ${{ github.repository }} --verify-tag --generate-notes --title "Release ${{ github.ref_name }}" | ||
gh release upload ${{ github.ref_name }} --repo ${{ github.repository }} dist/* | ||
- name: PyPI Publish package | ||
# hash for release/v1.8 | ||
uses: pypa/gh-action-pypi-publish@0bf742be3ebe032c25dd15117957dc15d0cfc38d | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters