-
Notifications
You must be signed in to change notification settings - Fork 5
Add GitHub action to automatically publish to PyPI #43
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -9,3 +9,5 @@ updates: | |
| actions: | ||
| patterns: | ||
| - "*" | ||
| cooldown: | ||
| default-days: 14 | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,95 @@ | ||||||||||||||||||||||||||
| name: Build Wheel and Release | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||
| - main | ||||||||||||||||||||||||||
| tags: | ||||||||||||||||||||||||||
| - "[0-9]+.[0-9]+.[0-9]+*" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||
|
Comment on lines
+11
to
+12
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above:
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||
| build-artifacts: | ||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||
| defaults: | ||||||||||||||||||||||||||
| run: | ||||||||||||||||||||||||||
| shell: bash -l {0} | ||||||||||||||||||||||||||
|
Comment on lines
+15
to
+19
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||
| - name: Checkout | ||||||||||||||||||||||||||
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||||||||||
| persist-credentials: false | ||||||||||||||||||||||||||
| - name: Set up Python | ||||||||||||||||||||||||||
| uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| python-version: "3.9" | ||||||||||||||||||||||||||
| - name: Install build dependencies | ||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||||||
| python -m pip install build twine | ||||||||||||||||||||||||||
| - name: Build wheel and sdist | ||||||||||||||||||||||||||
| run: python -m build | ||||||||||||||||||||||||||
| - uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| name: releases | ||||||||||||||||||||||||||
| path: dist | ||||||||||||||||||||||||||
| if-no-files-found: error | ||||||||||||||||||||||||||
| - name: Check with twine | ||||||||||||||||||||||||||
| run: python -m twine check --strict dist/* | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| upload-to-test-pypi: | ||||||||||||||||||||||||||
| needs: build-artifacts | ||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||
| if: github.repository == 'scientific-python/spatch' && startsWith(github.ref, 'refs/tags/') | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||
| name: test-pypi | ||||||||||||||||||||||||||
| url: https://test.pypi.org/p/spatch | ||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||
| id-token: write | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||
| - uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| name: releases | ||||||||||||||||||||||||||
| path: dist | ||||||||||||||||||||||||||
| - name: Publish to Test-PyPI | ||||||||||||||||||||||||||
| uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| repository-url: https://test.pypi.org/legacy/ | ||||||||||||||||||||||||||
| print-hash: true | ||||||||||||||||||||||||||
| verbose: true | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| upload-to-pypi: | ||||||||||||||||||||||||||
| needs: build-artifacts | ||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||
| if: github.repository == 'scientific-python/spatch' && startsWith(github.ref, 'refs/tags/') | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||
| name: pypi | ||||||||||||||||||||||||||
| url: https://pypi.org/p/spatch | ||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||
| id-token: write | ||||||||||||||||||||||||||
| attestations: write | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||
| - uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| name: releases | ||||||||||||||||||||||||||
| path: dist | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Generate artifact attestation for sdist and wheel | ||||||||||||||||||||||||||
| uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| subject-path: "dist/spatch-*" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - name: Publish to PyPI | ||||||||||||||||||||||||||
| uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 | ||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||
| attestations: true | ||||||||||||||||||||||||||
| print-hash: true | ||||||||||||||||||||||||||
| verbose: true | ||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ default_language_version: | |
| python: python3 | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v5.0.0 | ||
| rev: v6.0.0 | ||
| hooks: | ||
| # Sanity checks | ||
| - id: check-added-large-files | ||
|
|
@@ -55,22 +55,22 @@ repos: | |
| args: [--in-place] | ||
| # Let's keep `pyupgrade` even though `ruff --fix` probably does most of it | ||
| - repo: https://github.com/asottile/pyupgrade | ||
| rev: v3.20.0 | ||
| rev: v3.21.2 | ||
| hooks: | ||
| - id: pyupgrade | ||
| args: [--py310-plus] | ||
| # black often looks better than ruff-format | ||
| - repo: https://github.com/psf/black-pre-commit-mirror | ||
| rev: 25.1.0 | ||
| rev: 25.11.0 | ||
| hooks: | ||
| - id: black | ||
| - repo: https://github.com/adamchainz/blacken-docs | ||
| rev: 1.19.1 | ||
| rev: 1.20.0 | ||
| hooks: | ||
| - id: blacken-docs | ||
| additional_dependencies: [black==25.1.0] | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.12.5 | ||
| rev: v0.14.7 | ||
| hooks: | ||
| - id: ruff-check | ||
| args: [--fix-only, --show-fixes] | ||
|
|
@@ -87,7 +87,7 @@ repos: | |
| - id: auto-walrus | ||
| args: [--line-length, "100"] | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.12.5 | ||
| rev: v0.14.7 | ||
| hooks: | ||
| - id: ruff-check | ||
| # - id: ruff-format # Prefer black, but may temporarily uncomment this to see | ||
|
|
@@ -99,12 +99,12 @@ repos: | |
| # - id: pyroma | ||
| # args: [-n, "9", .] # Need author email to score a 10 | ||
| - repo: https://github.com/rbubley/mirrors-prettier | ||
| rev: v3.6.2 | ||
| rev: v3.7.3 | ||
| hooks: | ||
| - id: prettier | ||
| args: [--prose-wrap=preserve] | ||
| - repo: https://github.com/sphinx-contrib/sphinx-lint | ||
| rev: v1.0.0 | ||
| rev: v1.0.2 | ||
| hooks: | ||
| - id: sphinx-lint | ||
| args: [--enable, all, "--disable=line-too-long,leaked-markup"] | ||
|
|
@@ -128,13 +128,13 @@ repos: | |
| hooks: | ||
| - id: yamllint | ||
| - repo: https://github.com/python-jsonschema/check-jsonschema | ||
| rev: 0.33.2 | ||
| rev: 0.35.0 | ||
| hooks: | ||
| - id: check-dependabot | ||
| - id: check-github-workflows | ||
| # TODO: get zizmor to pass, and maybe set it up as a github action | ||
| # - repo: https://github.com/woodruffw/zizmor-pre-commit | ||
| # rev: v1.11.0 | ||
| # rev: v1.18.0 | ||
| # hooks: | ||
| # - id: zizmor | ||
|
Comment on lines
135
to
139
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know that this is outside the scope of setting up a publishing action, but I wanted to note that this is a TODO lying around outside the diff of this PR, and it'll help secure the publishing process when resolved. So it might make sense to resolve this here itself. A pre-commit hook is better than an action here, as it'll run in the pre-commit checks job, and you'd avoid adding another action this way. |
||
| - repo: local | ||
|
|
@@ -154,7 +154,7 @@ repos: | |
| language: pygrep | ||
| entry: "^permalink:.*_.*" | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v5.0.0 | ||
| rev: v6.0.0 | ||
| hooks: | ||
| - id: no-commit-to-branch # No commit directly to main | ||
| - repo: meta | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These permissions can go down into the context of the job, and then this can simply be:
so that the permissions are more granularly divided/scoped.