-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/push to pypi workflow #147
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: dev
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 | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,90 @@ | ||||||
| name: Publish Python 🐍 distribution 📦 to PyPI | ||||||
|
|
||||||
| on: push | ||||||
|
|
||||||
| jobs: | ||||||
| build: | ||||||
| name: Build distribution 📦 | ||||||
| runs-on: ubuntu-latest | ||||||
|
|
||||||
| steps: | ||||||
| - uses: actions/checkout@v4 | ||||||
| - name: Set up Python | ||||||
| uses: actions/setup-python@v5 | ||||||
| with: | ||||||
| python-version: "3.10.12" | ||||||
| - name: Install specific setuptools and pip | ||||||
| run: | | ||||||
| python -m pip install setuptools==65.5.0 pip==21 | ||||||
Zach-Attach marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| - name: Install pypa/build | ||||||
Zach-Attach marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| run: | | ||||||
| python3 -m pip install build --user | ||||||
|
Collaborator
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. Why does this change from python to python3? Seems inconsistent
Collaborator
Author
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 agree, let's make it |
||||||
| - 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: | ||||||
| name: >- | ||||||
| Publish Python 🐍 distribution 📦 to PyPI | ||||||
| if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||||||
|
Collaborator
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. So this is triggered by pushing a new tag? Does this mean we still need to push a new tag? This is how I would imagine it:
The particular if statement solution for seeing if it is being pushed to main or is just a PR for main can be found in the docs workflow, see https://github.com/buildingamind/NewbornEmbodiedTuringTest/blob/bf29953ab909ae216eb67a06fb9dbda281b9def1/.github/workflows/docs.yml#L3C1-L11C12
Collaborator
Author
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. To be honest I don't have an opinion, I'm fine if we do this either way, but if what you have is already how |
||||||
| needs: | ||||||
| - build | ||||||
| runs-on: ubuntu-latest | ||||||
| environment: | ||||||
| name: pypi | ||||||
| url: https://pypi.org/p/nett-benchmarkse | ||||||
|
Collaborator
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. Typo:
Suggested change
Collaborator
Author
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. Good catch, thanks |
||||||
| permissions: | ||||||
| id-token: write | ||||||
|
|
||||||
| 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: | ||||||
| - publish-to-pypi | ||||||
| runs-on: ubuntu-latest | ||||||
|
|
||||||
| permissions: | ||||||
| contents: write # IMPORTANT: mandatory for making GitHub Releases | ||||||
| id-token: write # IMPORTANT: mandatory for sigstore | ||||||
|
|
||||||
| steps: | ||||||
| - 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/gh-action-sigstore-python@v2.1.1 | ||||||
Zach-Attach marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| 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 }} | ||||||
| run: >- | ||||||
| gh release upload | ||||||
| '${{ github.ref_name }}' dist/** | ||||||
| --repo '${{ github.repository }}' | ||||||
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.
Minor suggestion (feel free to ignore): Caching would greatly help with build times here. See: https://github.com/buildingamind/NewbornEmbodiedTuringTest/blob/bf29953ab909ae216eb67a06fb9dbda281b9def1/.github/workflows/docs.yml#L27C6-L42C47
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.
For bonus points, building this once and then using it for both docs.yml and publish-to-test.yml would be nice and efficient.