-
Notifications
You must be signed in to change notification settings - Fork 0
Workflows #13
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
Workflows #13
Changes from 4 commits
28debba
a193c07
242d974
1ba9ef7
621b647
7b59278
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,72 +1,92 @@ | ||||||||||||||||||||||||||||||||
| # This workflow will upload a Python Package to PyPI when a release is created | ||||||||||||||||||||||||||||||||
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # This workflow uses actions that are not certified by GitHub. | ||||||||||||||||||||||||||||||||
| # They are provided by a third-party and are governed by | ||||||||||||||||||||||||||||||||
| # separate terms of service, privacy policy, and support | ||||||||||||||||||||||||||||||||
| # documentation. | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| name: Upload Python Package | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||
| release: | ||||||||||||||||||||||||||||||||
| types: [published] | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| name: Publish Python distribution to PyPI | ||||||||||||||||||||||||||||||||
| on: push | ||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||
| release-build: | ||||||||||||||||||||||||||||||||
| lint-and-test: | ||||||||||||||||||||||||||||||||
| if: github.ref_type == 'tag' | ||||||||||||||||||||||||||||||||
| name: Run linter and tests | ||||||||||||||||||||||||||||||||
| uses: ./.github/workflows/Lint-and-test.yml | ||||||||||||||||||||||||||||||||
| build: | ||||||||||||||||||||||||||||||||
| needs: lint-and-test | ||||||||||||||||||||||||||||||||
| if: github.ref_type == 'tag' | ||||||||||||||||||||||||||||||||
| name: build distribution | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - uses: actions/setup-python@v5 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| python-version: "3.x" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Build release distributions | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| # NOTE: put your own distribution build steps here. | ||||||||||||||||||||||||||||||||
| python -m pip install build | ||||||||||||||||||||||||||||||||
| python -m build | ||||||||||||||||||||||||||||||||
| - name: Upload distributions | ||||||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: release-dists | ||||||||||||||||||||||||||||||||
| path: dist/ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| pypi-publish: | ||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
| - name: Set up Python | ||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| python-version: "3.11" | ||||||||||||||||||||||||||||||||
| - name: Install pypa/build | ||||||||||||||||||||||||||||||||
| run: >- | ||||||||||||||||||||||||||||||||
| python3 -m | ||||||||||||||||||||||||||||||||
| pip install | ||||||||||||||||||||||||||||||||
| build | ||||||||||||||||||||||||||||||||
| --user | ||||||||||||||||||||||||||||||||
| - name: Build a binary wheel and a source tarball | ||||||||||||||||||||||||||||||||
| run: python3 -m build | ||||||||||||||||||||||||||||||||
| - name: Store the distribution packages | ||||||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: python-package-distributions | ||||||||||||||||||||||||||||||||
| path: dist/ | ||||||||||||||||||||||||||||||||
| publish-to-pypi: | ||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+35
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 7 months ago To fix the issue, we need to add explicit permissions blocks to the
Suggested changeset
1
.github/workflows/python-publish.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Refresh and try again.
|
||||||||||||||||||||||||||||||||
| name: >- | ||||||||||||||||||||||||||||||||
| Publish Python distribution to PyPI | ||||||||||||||||||||||||||||||||
| if: github.ref_type == 'tag' | ||||||||||||||||||||||||||||||||
| needs: [lint-and-test, build] | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
| needs: | ||||||||||||||||||||||||||||||||
| - release-build | ||||||||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||||||||
| name: release | ||||||||||||||||||||||||||||||||
| url: https://pypi.org/p/lewis | ||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||
| # IMPORTANT: this permission is mandatory for trusted publishing | ||||||||||||||||||||||||||||||||
| id-token: write | ||||||||||||||||||||||||||||||||
| id-token: write # IMPORTANT: mandatory for trusted publishing | ||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Download all the dists | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: python-package-distributions | ||||||||||||||||||||||||||||||||
| path: dist/ | ||||||||||||||||||||||||||||||||
| - name: Publish distribution to PyPI | ||||||||||||||||||||||||||||||||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||||||||||||||||||||||||||||||||
| github-release: | ||||||||||||||||||||||||||||||||
| name: >- | ||||||||||||||||||||||||||||||||
| Sign the Python distribution with Sigstore | ||||||||||||||||||||||||||||||||
| and upload them to GitHub Release | ||||||||||||||||||||||||||||||||
| needs: [lint-and-test, build, publish-to-pypi] | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Dedicated environments with protections for publishing are strongly recommended. | ||||||||||||||||||||||||||||||||
| # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules | ||||||||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||||||||
| name: pypi | ||||||||||||||||||||||||||||||||
| # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: | ||||||||||||||||||||||||||||||||
| # url: https://pypi.org/p/YOURPROJECT | ||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||
| # ALTERNATIVE: if your GitHub Release name is the PyPI project version string | ||||||||||||||||||||||||||||||||
| # ALTERNATIVE: exactly, uncomment the following line instead: | ||||||||||||||||||||||||||||||||
| # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} | ||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||
| contents: write # IMPORTANT: mandatory for making GitHub Releases | ||||||||||||||||||||||||||||||||
| id-token: write # IMPORTANT: mandatory for sigstore | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| - name: Retrieve release distributions | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: release-dists | ||||||||||||||||||||||||||||||||
| path: dist/ | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Publish release distributions to PyPI | ||||||||||||||||||||||||||||||||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| packages-dir: dist/ | ||||||||||||||||||||||||||||||||
| - name: Download all the dists | ||||||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| name: python-package-distributions | ||||||||||||||||||||||||||||||||
| path: dist/ | ||||||||||||||||||||||||||||||||
| - name: Sign the dists with Sigstore | ||||||||||||||||||||||||||||||||
| uses: sigstore/[email protected] | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| inputs: >- | ||||||||||||||||||||||||||||||||
| ./dist/*.tar.gz | ||||||||||||||||||||||||||||||||
| ./dist/*.whl | ||||||||||||||||||||||||||||||||
| - name: Create GitHub Release | ||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||
| GITHUB_TOKEN: ${{ github.token }} | ||||||||||||||||||||||||||||||||
| run: >- | ||||||||||||||||||||||||||||||||
| gh release create | ||||||||||||||||||||||||||||||||
| '${{ github.ref_name }}' | ||||||||||||||||||||||||||||||||
| --repo '${{ github.repository }}' | ||||||||||||||||||||||||||||||||
| --notes "" | ||||||||||||||||||||||||||||||||
| - name: Upload artifact signatures to GitHub Release | ||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||
| GITHUB_TOKEN: ${{ github.token }} | ||||||||||||||||||||||||||||||||
| # Upload to GitHub Release using the `gh` CLI. | ||||||||||||||||||||||||||||||||
| # `dist/` contains the built packages, and the | ||||||||||||||||||||||||||||||||
| # sigstore-produced signatures and certificates. | ||||||||||||||||||||||||||||||||
| run: >- | ||||||||||||||||||||||||||||||||
| gh release upload | ||||||||||||||||||||||||||||||||
| '${{ github.ref_name }}' dist/** | ||||||||||||||||||||||||||||||||
| --repo '${{ github.repository }}' | ||||||||||||||||||||||||||||||||
Check warning
Code scanning / CodeQL
Workflow does not contain permissions
Copilot Autofix
AI 7 months ago
To fix the issue, we will add a
permissionsblock to thelint-and-testjob. Since this job does not appear to require write access, we will set the permissions tocontents: read, which is the minimal required permission for most workflows. This change ensures that the job has only the access it needs, reducing the risk of misuse.