diff --git a/.github/workflows/ci-wheels.yml b/.github/workflows/ci-wheels.yml new file mode 100644 index 0000000..72407d7 --- /dev/null +++ b/.github/workflows/ci-wheels.yml @@ -0,0 +1,120 @@ +# Reference: +# - https://github.com/actions/checkout +# - https://github.com/actions/download-artifact +# - https://github.com/actions/upload-artifact +# - https://github.com/pypa/cibuildwheel +# - https://github.com/pypa/build +# - https://github.com/pypa/gh-action-pypi-publish +# - https://test.pypi.org/help/#apitoken + +name: ci-wheels + +on: + pull_request: + + push: + branches: + - "main" + - "v*x" + - "!auto-update-lockfiles" + - "!pre-commit-ci-update-config" + - "!dependabot/*" + tags: + - "v*" + +jobs: + build_bdist: + name: "build ${{ matrix.os }} (${{ matrix.arch }}) wheels" + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: ["ubuntu-latest", "macos-latest", "windows-latest"] + arch: ["x86_64", "arm64"] + exclude: + - os: "ubuntu-latest" + arch: "arm64" + - os: "windows-latest" + arch: "x86_64" + - os: "windows-latest" + arch: "arm64" + include: + - os: "windows-latest" + arch: "AMD64" + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + build_sdist: + name: "Build sdist" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: "Building sdist" + shell: bash + run: | + pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: pypi-sdist + path: ${{ github.workspace }}/dist/*.tar.gz + + + show-artifacts: + needs: [build_bdist, build_sdist] + name: "Show artifacts" + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: ${{ github.workspace }}/dist + + - shell: bash + run: | + ls -l ${{ github.workspace }}/dist + + + publish-artifacts-test-pypi: + needs: [build_bdist, build_sdist] + name: "Publish to Test PyPI" + runs-on: ubuntu-latest + # upload to Test PyPI for every commit on main branch + if: github.event_name == 'push' && github.event.ref == 'refs/heads/main' + steps: + - uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: ${{ github.workspace }}/dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI }} + repository_url: https://test.pypi.org/legacy/ + skip_existing: true + print_hash: true + + publish-artifacts-pypi: + needs: [build_bdist, build_sdist] + name: "Publish to PyPI" + runs-on: ubuntu-latest + # upload to PyPI for every tag starting with 'v' + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') + steps: + - uses: actions/download-artifact@v4 + with: + merge-multiple: true + path: ${{ github.workspace }}/dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI }} + print_hash: true \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 94ddbee..7b31d31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,5 +10,4 @@ requires = [ "wheel", ] # Defined by PEP 517 -build-backend = "setuptools.build_meta" - +build-backend = "setuptools.build_meta" \ No newline at end of file