From 4806a139d73b05a923a29a28c92f21abe379239e Mon Sep 17 00:00:00 2001 From: Loren Eteval Date: Wed, 28 Feb 2024 19:13:18 +0800 Subject: [PATCH] Update github workflow Signed-off-by: Loren Eteval --- .github/workflows/deploy-pypi.yml | 68 +++++++++++++++++++++++++++++++ .github/workflows/wheels.yml | 34 ---------------- 2 files changed, 68 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/deploy-pypi.yml delete mode 100644 .github/workflows/wheels.yml diff --git a/.github/workflows/deploy-pypi.yml b/.github/workflows/deploy-pypi.yml new file mode 100644 index 0000000..6e55c51 --- /dev/null +++ b/.github/workflows/deploy-pypi.yml @@ -0,0 +1,68 @@ +name: Deploy PyPI + +on: [push, pull_request] + +jobs: + build_xray: + name: ${{ matrix.os }} Python ${{ matrix.python-version }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-latest, windows-2019, windows-2022, windows-latest, macos-11, macos-12, macos-13, macos-14, macos-latest] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-go@v4 + with: + go-version: "1.21" + - run: go version + + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - run: python --version + + - name: Install setuptools, wheel + run: >- + python -m + pip install + setuptools wheel + + - name: Build source tarball + run: python setup.py sdist + + - name: Install from source + run: python setup.py install + + - name: Run sample.py + run: python sample/sample.py + + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + 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 + needs: + - build_xray + runs-on: ubuntu-latest + environment: + name: deploy-pypi + url: https://pypi.org/p/Xray-core-python + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml deleted file mode 100644 index ac8e062..0000000 --- a/.github/workflows/wheels.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Build Xray-core binding - -on: [push, pull_request] - -jobs: - build_xray: - name: ${{ matrix.os }} Python ${{ matrix.python-version }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-20.04, ubuntu-22.04, windows-2019, windows-2022, macos-11, macos-12, macos-13] - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] - - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-go@v4 - with: - go-version: "1.21.0" - - run: go version - - - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - run: python --version - - - name: Generate source distribution - run: python setup.py sdist - - - name: Install from source - run: python setup.py install - - - name: Run sample.py - run: python sample/sample.py \ No newline at end of file