Skip to content

Publish to test.pypi.org; Reduce permission scope of release action #1154

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
61 changes: 41 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,12 @@ jobs:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

prepare-release-notes:
name: Prepare Release Notes
needs: [lint]
create-github-release:
name: Create GitHub release
needs: [lint, check]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -182,13 +184,45 @@ jobs:
with:
name: release-notes.md
path: release-notes.md
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Create GitHub Release
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
with:
name: pytest-asyncio ${{ needs.lint.outputs.version }}
artifacts: dist/*
bodyFile: release-notes.md
prerelease: ${{ needs.lint.outputs.prerelease }}
token: ${{ secrets.GITHUB_TOKEN }}

publish-test-pypi:
name: Publish packages to test.pypi.org
environment: release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [lint, check]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Download distributions
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Upload to test.pypi.org
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
with:
repository-url: https://test.pypi.org/legacy/

deploy:
name: Deploy
publish-pypi:
name: Publish packages to pypi.org
environment: release
# Run only on pushing a tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
needs: [lint, check, prepare-release-notes]
needs: [lint, check]
runs-on: ubuntu-latest
permissions:
id-token: write
Expand All @@ -203,16 +237,3 @@ jobs:
tree dist
- name: PyPI upload
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4
- name: Download Release Notes
uses: actions/download-artifact@v4
with:
name: release-notes.md
path: release-notes.md
- name: GitHub Release
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
with:
name: pytest-asyncio ${{ needs.lint.outputs.version }}
artifacts: dist/*
bodyFile: release-notes.md
prerelease: ${{ needs.lint.outputs.prerelease }}
token: ${{ secrets.GITHUB_TOKEN }}
Loading