diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 000000000..ebf02824d --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,93 @@ +name: Endstone CD + +on: + push: + branches: + - next + tags: + - '*' + workflow_dispatch: + +jobs: + build_wheels: + name: Build wheel for ${{ matrix.python }}-${{ matrix.machine.platform }} on ${{ matrix.machine.os }} + strategy: + fail-fast: false + matrix: + machine: + - { os: 'windows-latest', platform: 'win_amd64' } + - { os: 'ubuntu-latest', platform: 'manylinux_x86_64' } + python: [ "cp39", "cp310", "cp311", "cp312" ] + runs-on: ${{ matrix.machine.os }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: ilammy/msvc-dev-cmd@v1 + with: + toolset: 14.36 + vsversion: 2022 + + - name: Get latest CMake and Ninja + uses: lukka/get-cmake@latest + + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.2 + env: + CIBW_BUILD: ${{ matrix.python }}-${{ matrix.machine.platform }} + + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: endstone_${{ matrix.python }}-${{ matrix.machine.platform }}.whl + path: ./wheelhouse/*.whl + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: artifact + path: ./wheelhouse/*.whl + + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Build sdist + run: pipx run build --sdist + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: artifact + path: dist/*.tar.gz + + publish: + name: Publish + if: contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + needs: [ build_wheels, build_sdist ] + environment: pypi + permissions: + id-token: write + contents: write + + steps: + - name: Restore artifacts + uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: dist/* + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 92d7171ad..445d7bb8d 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -22,6 +22,8 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up GCC uses: egor-tensin/setup-gcc@v1 diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index eed3bd329..48745bfa0 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -21,6 +21,8 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 diff --git a/endstone_python/python/endstone/__init__.py b/endstone_python/python/endstone/__init__.py index 4f600e8b6..a1c235c4c 100644 --- a/endstone_python/python/endstone/__init__.py +++ b/endstone_python/python/endstone/__init__.py @@ -2,7 +2,7 @@ from packaging.version import Version -from _version import __version__, __version_tuple__ +from ._version import __version__, __version_tuple__ __minecraft__version__ = (lambda v: f"{v[0]}.{v[1]}.{v[2]}.{v[3]:02}")([int(a) for a in Version(__version__).release])