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

PyPI Publish GH Action #400

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Changes from 3 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
84 changes: 84 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Wheel building and publishing

on:
workflow_dispatch:
pull_request:
push:
branches:
- main #check branch
jdegenstein marked this conversation as resolved.
Show resolved Hide resolved
release:
types:
- published

jobs:
# may be useful to have a wheel building test here eventually (untested):
# test_wheel_building:
# #
# permissions:
# contents: none
# uses: someactionyml.yml #TODO: replace with wheel build action
# if: (github.event_name == 'push') # || github.event_name == 'pull_request')
# with:
# upload_to_pypi: false
# targets: |
# - cp311-manylinux_x86_64

# secrets:
# pypi_token: ${{ secrets.pypi_token }} # consider using alternate strategy

build_wheels:
# This does the actual wheel building or if triggered manually via the workflow dispatch, or for a tag.
# this job does NOT publish the wheels
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, windows-2022, macos-11]
if: (github.repository == 'gumyr/build123d' && ( startsWith(github.ref, 'refs/tags/v') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Build all wheels')))
steps:
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does cibuildwheel need to be installed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be wrong, but not to my knowledge. uses: pypa/[email protected] should install cibuildwheel within the GH action runner.


- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

# Do we need sdist wheels?
# build_sdist:
# name: Build source distribution
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4

# - name: Build sdist
# run: pipx run build --sdist

# - uses: actions/upload-artifact@v3
# with:
# path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels] #, build_sdist]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/build123d
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is https://pypi.org/p/build123d short for https://pypi.org/project/build123d? Do either work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is a shortcut and either will work (from PyPI docs)

permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
# if: github.event_name == 'release' && github.event.action == 'published'
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
if: (github.repository == 'gumyr/build123d' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
steps:
- uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@release/v1
with:
# To test: repository-url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
Loading