Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

publish-release: update to trusted publishers workflow #164

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ name: Create and Publish Release

jobs:
build:
name: Create and Publish Release
name: Build distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
Expand All @@ -23,7 +22,8 @@ jobs:
- name: Install release dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine
pip install --upgrade setuptools wheel build

- name: Get release notes
id: release_notes
run: |
Expand All @@ -34,6 +34,7 @@ jobs:
git fetch --tags --force
TAG_NAME=${GITHUB_REF/refs\/tags\//}
echo "$(git tag -l --format='%(contents)' $TAG_NAME)" > "${{ runner.temp }}/CHANGELOG.md"

- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
Expand All @@ -46,10 +47,34 @@ jobs:
draft: false
prerelease: false

- name: Build and publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/axisregistry*
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/axisregistry
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/[email protected]
with:
# repository-url: https://test.pypi.org/legacy/ # for testing purposes
verify-metadata: false # twine previously didn't verify metadata when uploading
Loading