diff --git a/.github/workflows/pypi-build-publish.yml b/.github/workflows/pypi-build-publish.yml new file mode 100644 index 0000000..edb090e --- /dev/null +++ b/.github/workflows/pypi-build-publish.yml @@ -0,0 +1,68 @@ +name: Build wheels for Linux/macOS, build sdist, and publish to PyPI + +on: + release: + types: published + +jobs: + build_wheels: + name: Build ${{ matrix.os }} wheels + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.17.0 + env: + CIBW_ARCHS_LINUX: x86_64 i686 aarch64 + CIBW_ARCHS_MACOS: x86_64 arm64 + with: + output-dir: ${{ runner.temp }}/cibw-build + + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ runner.os }} + path: ${{ runner.temp }}/cibw-build/*.whl + + 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@v4 + with: + name: sdist + path: dist/*.tar.gz + + pypi-publish: + name: Publish release to PyPI + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + environment: + name: PyPI + url: https://pypi.org/p/pytun-pmd3 + permissions: + id-token: write + + steps: + - uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + + - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.github/workflows/python-publish-macos-and-linux.yml b/.github/workflows/python-publish-macos-and-linux.yml deleted file mode 100644 index 5fb524d..0000000 --- a/.github/workflows/python-publish-macos-and-linux.yml +++ /dev/null @@ -1,48 +0,0 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Upload python package for macOS & linux - -on: - release: - types: [ created ] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - if: '! github.event.pull_request.draft' - runs-on: ${{ matrix.os }} - - strategy: - matrix: - include: - - os: macos-latest - arch: arm64 - - os: macos-latest - arch: x86_64 - - os: ubuntu-latest - arch: x86_64 - - os: ubuntu-latest - arch: i686 - - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -U build setuptools wheel twine cibuildwheel - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - CIBW_ARCHS: ${{ matrix.arch }} - run: | - cibuildwheel --output-dir dist - twine upload dist/* --skip-existing diff --git a/.github/workflows/python-publish-windows.yml b/.github/workflows/python-publish-windows.yml deleted file mode 100644 index 51caff1..0000000 --- a/.github/workflows/python-publish-windows.yml +++ /dev/null @@ -1,36 +0,0 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Upload python package for windows - -on: - release: - types: [ created ] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - if: '! github.event.pull_request.draft' - runs-on: windows-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -U build setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - CIBW_ARCHS: ${{ matrix.arch }} - run: | - python3 -m build - twine upload dist/* --skip-existing