From 858a820b03b0fe552389ba8bb24d320936a6680a Mon Sep 17 00:00:00 2001 From: "shuizhao.gh" Date: Mon, 17 Nov 2025 19:33:13 +0800 Subject: [PATCH 01/11] ci: fix build --- .github/workflows/release.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d9e4c2d..26562be 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,7 @@ jobs: pip install aliyun-log-fastpb --no-index --find-links dist --force-reinstall python -c "import aliyun_log_fastpb" - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wheels path: dist @@ -63,7 +63,7 @@ jobs: pip install aliyun-log-fastpb --no-index --find-links dist --force-reinstall python -c "import aliyun_log_fastpb" - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wheels path: dist @@ -91,7 +91,7 @@ jobs: pip install aliyun-log-fastpb --no-index --find-links dist --force-reinstall python -c "import aliyun_log_fastpb" - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wheels path: dist @@ -118,7 +118,7 @@ jobs: with: arch: ${{ matrix.target }} distro: ubuntu20.04 - githubToken: ${{ github.token }} + # githubToken: ${{ github.token }} install: | apt-get update apt-get install -y --no-install-recommends python3 python3-pip @@ -127,7 +127,7 @@ jobs: pip3 install aliyun-log-fastpb --no-index --find-links dist/ --force-reinstall python3 -c "import aliyun_log_fastpb" - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wheels path: dist @@ -163,7 +163,7 @@ jobs: pip3 install aliyun-log-fastpb --no-index --find-links /io/dist/ --force-reinstall python3 -c "import aliyun_log_fastpb" - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wheels path: dist @@ -201,7 +201,7 @@ jobs: pip3 install aliyun-log-fastpb --no-index --find-links dist/ --force-reinstall python3 -c "import aliyun_log_fastpb" - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: wheels path: dist From b02b43312dff0c59d17345e8f236fe9d751e59a4 Mon Sep 17 00:00:00 2001 From: "shuizhao.gh" Date: Mon, 17 Nov 2025 19:43:02 +0800 Subject: [PATCH 02/11] upgrade --- .github/workflows/release.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 26562be..7e6ff30 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,8 +11,8 @@ jobs: macos: runs-on: macos-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 @@ -47,8 +47,8 @@ jobs: matrix: target: [x64, x86] steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} architecture: ${{ matrix.target }} @@ -74,8 +74,8 @@ jobs: matrix: target: [x86_64, i686] steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 @@ -102,8 +102,8 @@ jobs: matrix: target: [aarch64, armv7, s390x, ppc64le, ppc64] steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} - name: Build wheels @@ -140,8 +140,8 @@ jobs: - x86_64-unknown-linux-musl - i686-unknown-linux-musl steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 @@ -178,8 +178,8 @@ jobs: - target: armv7-unknown-linux-musleabihf arch: armv7 steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} - name: Build wheels @@ -215,7 +215,7 @@ jobs: - uses: actions/download-artifact@v3 with: name: wheels - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} - name: Publish to PyPI From 30d09ff91728fd0938e8517f03795a92fb1a7d00 Mon Sep 17 00:00:00 2001 From: "shuizhao.gh" Date: Mon, 17 Nov 2025 19:46:35 +0800 Subject: [PATCH 03/11] use 3.12 --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7e6ff30..04fa8b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: pull_request: env: - PYTHON_VERSION: "3.9" + PYTHON_VERSION: "3.12" jobs: macos: @@ -16,6 +16,7 @@ jobs: with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 + cache: "pip" - uses: dtolnay/rust-toolchain@stable - name: Build wheels - x86_64 uses: PyO3/maturin-action@v1 From 084908d9e17d969cb52cddc5a23a8c81953695b7 Mon Sep 17 00:00:00 2001 From: "shuizhao.gh" Date: Mon, 17 Nov 2025 19:54:12 +0800 Subject: [PATCH 04/11] direct install --- .github/workflows/release.yml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 04fa8b7..fb3a74a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,8 +25,9 @@ jobs: args: --release --out dist --sdist - name: Install built wheel - x86_64 run: | - pip install aliyun-log-fastpb --no-index --find-links dist --force-reinstall + pip install dist/aliyun_log_fastpb-*.whl --force-reinstall python -c "import aliyun_log_fastpb" + rm -rf dist - name: Build wheels - universal2 uses: PyO3/maturin-action@v1 with: @@ -34,8 +35,9 @@ jobs: args: --release --out dist - name: Install built wheel - universal2 run: | - pip install aliyun-log-fastpb --no-index --find-links dist --force-reinstall + pip install dist/aliyun_log_fastpb-*.whl --force-reinstall python -c "import aliyun_log_fastpb" + rm -rf dist - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -61,8 +63,9 @@ jobs: args: --release --out dist - name: Install built wheel run: | - pip install aliyun-log-fastpb --no-index --find-links dist --force-reinstall + pip install dist/aliyun_log_fastpb-*.whl --force-reinstall python -c "import aliyun_log_fastpb" + rm -rf dist - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -89,8 +92,9 @@ jobs: - name: Install built wheel if: matrix.target == 'x86_64' run: | - pip install aliyun-log-fastpb --no-index --find-links dist --force-reinstall + pip install dist/aliyun_log_fastpb-*.whl --force-reinstall python -c "import aliyun_log_fastpb" + rm -rf dist - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -125,8 +129,9 @@ jobs: apt-get install -y --no-install-recommends python3 python3-pip pip3 install -U pip run: | - pip3 install aliyun-log-fastpb --no-index --find-links dist/ --force-reinstall + pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall python3 -c "import aliyun_log_fastpb" + rm -rf dist - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -161,8 +166,9 @@ jobs: run: | apk add py3-pip pip3 install -U pip - pip3 install aliyun-log-fastpb --no-index --find-links /io/dist/ --force-reinstall + pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall python3 -c "import aliyun_log_fastpb" + rm -rf dist - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -199,8 +205,9 @@ jobs: apk add py3-pip pip3 install -U pip run: | - pip3 install aliyun-log-fastpb --no-index --find-links dist/ --force-reinstall + pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall python3 -c "import aliyun_log_fastpb" + rm -rf dist - name: Upload wheels uses: actions/upload-artifact@v4 with: From 806a3794cf63256029e5b152ef97fe5f44ad3d5e Mon Sep 17 00:00:00 2001 From: "shuizhao.gh" Date: Mon, 17 Nov 2025 20:10:35 +0800 Subject: [PATCH 05/11] upload condition --- .github/workflows/release.yml | 91 +++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 31 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fb3a74a..a42ae23 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,45 +3,66 @@ name: Python on: push: pull_request: + workflow_dispatch: + inputs: + upload-artifacts: + description: '是否上传构建产物 (Upload artifacts)' + required: false + default: 'false' + type: choice + options: + - 'true' + - 'false' env: PYTHON_VERSION: "3.12" jobs: + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' + uses: actions/upload-artifact@v4 + with: + name: wheels-sdist + path: dist + macos: runs-on: macos-latest + strategy: + matrix: + target: [x86_64, universal2-apple-darwin] steps: - uses: actions/checkout@v5 - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} architecture: x64 - cache: "pip" - uses: dtolnay/rust-toolchain@stable - - name: Build wheels - x86_64 - uses: PyO3/maturin-action@v1 - with: - target: x86_64 - args: --release --out dist --sdist - - name: Install built wheel - x86_64 - run: | - pip install dist/aliyun_log_fastpb-*.whl --force-reinstall - python -c "import aliyun_log_fastpb" - rm -rf dist - - name: Build wheels - universal2 + - name: Build wheels uses: PyO3/maturin-action@v1 with: - target: universal2-apple-darwin + target: ${{ matrix.target }} args: --release --out dist - - name: Install built wheel - universal2 + - name: Install built wheel run: | pip install dist/aliyun_log_fastpb-*.whl --force-reinstall python -c "import aliyun_log_fastpb" - rm -rf dist - name: Upload wheels + if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' uses: actions/upload-artifact@v4 with: - name: wheels + name: wheels-macos-${{ matrix.target }} path: dist windows: @@ -65,11 +86,11 @@ jobs: run: | pip install dist/aliyun_log_fastpb-*.whl --force-reinstall python -c "import aliyun_log_fastpb" - rm -rf dist - name: Upload wheels + if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' uses: actions/upload-artifact@v4 with: - name: wheels + name: wheels-windows-${{ matrix.target }} path: dist linux: @@ -94,11 +115,11 @@ jobs: run: | pip install dist/aliyun_log_fastpb-*.whl --force-reinstall python -c "import aliyun_log_fastpb" - rm -rf dist - name: Upload wheels + if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' uses: actions/upload-artifact@v4 with: - name: wheels + name: wheels-linux-${{ matrix.target }} path: dist linux-cross: @@ -131,11 +152,11 @@ jobs: run: | pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall python3 -c "import aliyun_log_fastpb" - rm -rf dist - name: Upload wheels + if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' uses: actions/upload-artifact@v4 with: - name: wheels + name: wheels-linux-cross-${{ matrix.target }} path: dist musllinux: @@ -168,11 +189,11 @@ jobs: pip3 install -U pip pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall python3 -c "import aliyun_log_fastpb" - rm -rf dist - name: Upload wheels + if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' uses: actions/upload-artifact@v4 with: - name: wheels + name: wheels-musllinux-${{ matrix.target }} path: dist musllinux-cross: @@ -207,29 +228,37 @@ jobs: run: | pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall python3 -c "import aliyun_log_fastpb" - rm -rf dist - name: Upload wheels + if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' uses: actions/upload-artifact@v4 with: - name: wheels + name: wheels-musllinux-cross-${{ matrix.platform.arch }} path: dist release: name: Release runs-on: ubuntu-latest - if: "startsWith(github.ref, 'refs/tags/')" - needs: [ macos, windows, linux, linux-cross, musllinux, musllinux-cross ] + if: startsWith(github.ref, 'refs/tags/') + needs: [ sdist, macos, windows, linux, linux-cross, musllinux, musllinux-cross ] steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: - name: wheels + pattern: wheels-* + path: dist + merge-multiple: true - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} + - name: List all files to be uploaded + run: | + ls -lh dist/ + echo "---" + echo "Files to upload:" + ls dist/ - name: Publish to PyPI env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | pip install --upgrade twine - twine upload --skip-existing * \ No newline at end of file + twine upload --skip-existing dist/* \ No newline at end of file From 391a3777685d97e3a1f3e4a9db529618c758623e Mon Sep 17 00:00:00 2001 From: "shuizhao.gh" Date: Mon, 17 Nov 2025 20:27:31 +0800 Subject: [PATCH 06/11] fix musl --- .github/workflows/release.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a42ae23..d3d5e12 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,6 +55,8 @@ jobs: target: ${{ matrix.target }} args: --release --out dist - name: Install built wheel + # 只在 universal2 上测试,x86_64 只构建不测试 + if: matrix.target == 'universal2-apple-darwin' run: | pip install dist/aliyun_log_fastpb-*.whl --force-reinstall python -c "import aliyun_log_fastpb" @@ -83,6 +85,7 @@ jobs: target: ${{ matrix.target }} args: --release --out dist - name: Install built wheel + shell: bash run: | pip install dist/aliyun_log_fastpb-*.whl --force-reinstall python -c "import aliyun_log_fastpb" @@ -186,8 +189,8 @@ jobs: options: -v ${{ github.workspace }}:/io -w /io run: | apk add py3-pip - pip3 install -U pip - pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall + pip3 install -U pip --break-system-packages + pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall --break-system-packages python3 -c "import aliyun_log_fastpb" - name: Upload wheels if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' @@ -224,9 +227,9 @@ jobs: githubToken: ${{ github.token }} install: | apk add py3-pip - pip3 install -U pip + pip3 install -U pip --break-system-packages run: | - pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall + pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall --break-system-packages python3 -c "import aliyun_log_fastpb" - name: Upload wheels if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' From fb4bc7ad98cb0158e88ae11ff33def6c92c1e71e Mon Sep 17 00:00:00 2001 From: "shuizhao.gh" Date: Mon, 17 Nov 2025 22:18:26 +0800 Subject: [PATCH 07/11] add draft --- .github/workflows/release.yml | 266 ++++++++++++++++++---------------- 1 file changed, 144 insertions(+), 122 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d3d5e12..08dd72d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,8 +5,8 @@ on: pull_request: workflow_dispatch: inputs: - upload-artifacts: - description: '是否上传构建产物 (Upload artifacts)' + draft: + description: '是否是草稿版本 Release (Create draft release)' required: false default: 'false' type: choice @@ -15,7 +15,7 @@ on: - 'false' env: - PYTHON_VERSION: "3.12" + PYTHON_VERSION: '3.12' jobs: sdist: @@ -31,11 +31,11 @@ jobs: command: sdist args: --out dist - name: Upload sdist - if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' uses: actions/upload-artifact@v4 with: name: wheels-sdist path: dist + overwrite: true macos: runs-on: macos-latest @@ -61,11 +61,11 @@ jobs: pip install dist/aliyun_log_fastpb-*.whl --force-reinstall python -c "import aliyun_log_fastpb" - name: Upload wheels - if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' uses: actions/upload-artifact@v4 with: name: wheels-macos-${{ matrix.target }} path: dist + overwrite: true windows: runs-on: windows-latest @@ -90,11 +90,11 @@ jobs: pip install dist/aliyun_log_fastpb-*.whl --force-reinstall python -c "import aliyun_log_fastpb" - name: Upload wheels - if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' uses: actions/upload-artifact@v4 with: name: wheels-windows-${{ matrix.target }} path: dist + overwrite: true linux: runs-on: ubuntu-latest @@ -102,28 +102,28 @@ jobs: matrix: target: [x86_64, i686] steps: - - uses: actions/checkout@v5 - - uses: actions/setup-python@v6 - with: - python-version: ${{ env.PYTHON_VERSION }} - architecture: x64 - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - manylinux: auto - args: --release --out dist - - name: Install built wheel - if: matrix.target == 'x86_64' - run: | - pip install dist/aliyun_log_fastpb-*.whl --force-reinstall - python -c "import aliyun_log_fastpb" - - name: Upload wheels - if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' - uses: actions/upload-artifact@v4 - with: - name: wheels-linux-${{ matrix.target }} - path: dist + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 + with: + python-version: ${{ env.PYTHON_VERSION }} + architecture: x64 + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + manylinux: auto + args: --release --out dist + - name: Install built wheel + if: matrix.target == 'x86_64' + run: | + pip install dist/aliyun_log_fastpb-*.whl --force-reinstall + python -c "import aliyun_log_fastpb" + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-${{ matrix.target }} + path: dist + overwrite: true linux-cross: runs-on: ubuntu-latest @@ -131,36 +131,36 @@ jobs: matrix: target: [aarch64, armv7, s390x, ppc64le, ppc64] steps: - - uses: actions/checkout@v5 - - uses: actions/setup-python@v6 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - manylinux: auto - args: --release --out dist - - uses: uraimo/run-on-arch-action@v3.0.1 - if: matrix.target != 'ppc64' - name: Install built wheel - with: - arch: ${{ matrix.target }} - distro: ubuntu20.04 - # githubToken: ${{ github.token }} - install: | - apt-get update - apt-get install -y --no-install-recommends python3 python3-pip - pip3 install -U pip - run: | - pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall - python3 -c "import aliyun_log_fastpb" - - name: Upload wheels - if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' - uses: actions/upload-artifact@v4 - with: - name: wheels-linux-cross-${{ matrix.target }} - path: dist + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + manylinux: auto + args: --release --out dist + - uses: uraimo/run-on-arch-action@v3.0.1 + if: matrix.target != 'ppc64' + name: Install built wheel + with: + arch: ${{ matrix.target }} + distro: ubuntu20.04 + # githubToken: ${{ github.token }} + install: | + apt-get update + apt-get install -y --no-install-recommends python3 python3-pip + pip3 install -U pip + run: | + pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall + python3 -c "import aliyun_log_fastpb" + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-linux-cross-${{ matrix.target }} + path: dist + overwrite: true musllinux: runs-on: ubuntu-latest @@ -170,34 +170,34 @@ jobs: - x86_64-unknown-linux-musl - i686-unknown-linux-musl steps: - - uses: actions/checkout@v5 - - uses: actions/setup-python@v6 - with: - python-version: ${{ env.PYTHON_VERSION }} - architecture: x64 - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.target }} - manylinux: musllinux_1_2 - args: --release --out dist - - name: Install built wheel - if: matrix.target == 'x86_64-unknown-linux-musl' - uses: addnab/docker-run-action@v3 - with: - image: alpine:latest - options: -v ${{ github.workspace }}:/io -w /io - run: | - apk add py3-pip - pip3 install -U pip --break-system-packages - pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall --break-system-packages - python3 -c "import aliyun_log_fastpb" - - name: Upload wheels - if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' - uses: actions/upload-artifact@v4 - with: - name: wheels-musllinux-${{ matrix.target }} - path: dist + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 + with: + python-version: ${{ env.PYTHON_VERSION }} + architecture: x64 + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + manylinux: musllinux_1_2 + args: --release --out dist + - name: Install built wheel + if: matrix.target == 'x86_64-unknown-linux-musl' + uses: addnab/docker-run-action@v3 + with: + image: alpine:latest + options: -v ${{ github.workspace }}:/io -w /io + run: | + apk add py3-pip + pip3 install -U pip --break-system-packages + pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall --break-system-packages + python3 -c "import aliyun_log_fastpb" + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-musllinux-${{ matrix.target }} + path: dist + overwrite: true musllinux-cross: runs-on: ubuntu-latest @@ -209,40 +209,59 @@ jobs: - target: armv7-unknown-linux-musleabihf arch: armv7 steps: - - uses: actions/checkout@v5 - - uses: actions/setup-python@v6 - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Build wheels - uses: PyO3/maturin-action@v1 - with: - target: ${{ matrix.platform.target }} - manylinux: musllinux_1_2 - args: --release --out dist - - uses: uraimo/run-on-arch-action@v3.0.1 - name: Install built wheel - with: - arch: ${{ matrix.platform.arch }} - distro: alpine_latest - githubToken: ${{ github.token }} - install: | - apk add py3-pip - pip3 install -U pip --break-system-packages + - uses: actions/checkout@v5 + - uses: actions/setup-python@v6 + with: + python-version: ${{ env.PYTHON_VERSION }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.platform.target }} + manylinux: musllinux_1_2 + args: --release --out dist + - uses: uraimo/run-on-arch-action@v3.0.1 + name: Install built wheel + with: + arch: ${{ matrix.platform.arch }} + distro: alpine_latest + githubToken: ${{ github.token }} + install: | + apk add py3-pip + pip3 install -U pip --break-system-packages + run: | + pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall --break-system-packages + python3 -c "import aliyun_log_fastpb" + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: wheels-musllinux-cross-${{ matrix.platform.arch }} + path: dist + overwrite: true + + pre-release: + name: Pre-Release Check + runs-on: ubuntu-latest + needs: + [sdist, macos, windows, linux, linux-cross, musllinux, musllinux-cross] + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + pattern: wheels-* + path: dist + merge-multiple: true + - name: List all artifacts run: | - pip3 install dist/aliyun_log_fastpb-*.whl --force-reinstall --break-system-packages - python3 -c "import aliyun_log_fastpb" - - name: Upload wheels - if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.upload-artifacts == 'true' - uses: actions/upload-artifact@v4 - with: - name: wheels-musllinux-cross-${{ matrix.platform.arch }} - path: dist + echo "=== All build artifacts ===" + ls -lh dist/ + echo "" + echo "=== Total files: $(ls -1 dist/ | wc -l) ===" release: name: Release runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - needs: [ sdist, macos, windows, linux, linux-cross, musllinux, musllinux-cross ] + if: startsWith(github.ref, 'refs/tags/') || ${{ github.event.inputs.draft == 'true' }} + needs: [pre-release] steps: - uses: actions/download-artifact@v4 with: @@ -252,16 +271,19 @@ jobs: - uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} - - name: List all files to be uploaded - run: | - ls -lh dist/ - echo "---" - echo "Files to upload:" - ls dist/ + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + files: dist/* + draft: ${{ github.event.inputs.draft == 'true' }} + prerelease: false + generate_release_notes: true + fail_on_unmatched_files: true - name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/') env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | pip install --upgrade twine - twine upload --skip-existing dist/* \ No newline at end of file + twine upload --skip-existing dist/* From eb743f24d30303feace3de89abc07a757adf20a0 Mon Sep 17 00:00:00 2001 From: "shuizhao.gh" Date: Mon, 17 Nov 2025 22:28:01 +0800 Subject: [PATCH 08/11] add condition --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 08dd72d..e3c6894 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,8 @@ name: Python on: push: - pull_request: + tags: + - 'v*' workflow_dispatch: inputs: draft: From 292b59c1333ae0a62e8eaf943f07f214e52bb08a Mon Sep 17 00:00:00 2001 From: "shuizhao.gh" Date: Mon, 17 Nov 2025 22:30:42 +0800 Subject: [PATCH 09/11] add ci tests --- .github/workflows/test.yml | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..88f1f82 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,48 @@ +name: Tests + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +env: + PYTHON_VERSION: '3.12' + CARGO_TERM_COLOR: always + +jobs: + test: + name: Run Tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - name: Setup Python + uses: actions/setup-python@v6 + with: + python-version: ${{ env.PYTHON_VERSION }} + cache: 'pip' + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements-dev.txt + + - name: Run Cargo tests + run: cargo test --verbose + + - name: Build Python extension + run: | + pip install maturin + maturin develop + + - name: Run pytest + run: pytest -v tests/ + From 9bcedfbee7380714cd36a1eba378b0664f2feb0a Mon Sep 17 00:00:00 2001 From: "shuizhao.gh" Date: Mon, 17 Nov 2025 22:35:02 +0800 Subject: [PATCH 10/11] fix test --- .github/workflows/test.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 88f1f82..395164d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,6 +33,8 @@ jobs: - name: Install Python dependencies run: | python -m pip install --upgrade pip + python -m venv .venv + source .venv/bin/activate pip install -r requirements-dev.txt - name: Run Cargo tests @@ -40,9 +42,12 @@ jobs: - name: Build Python extension run: | + source .venv/bin/activate pip install maturin maturin develop - name: Run pytest - run: pytest -v tests/ + run: | + source .venv/bin/activate + pytest -v tests/ From 45de769b67102f6ef695fc21c82d3bd3a221f0c5 Mon Sep 17 00:00:00 2001 From: "shuizhao.gh" Date: Mon, 17 Nov 2025 22:45:02 +0800 Subject: [PATCH 11/11] add draft version --- .github/workflows/release.yml | 20 +++++++++----------- README.md | 2 ++ README_CN.md | 2 ++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3c6894..4347e20 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Python +name: Release on: push: @@ -6,14 +6,11 @@ on: - 'v*' workflow_dispatch: inputs: - draft: - description: '是否是草稿版本 Release (Create draft release)' + draft_version: + description: '草稿版本号 (Draft version tag, e.g., v0.1.0-beta1)' required: false - default: 'false' - type: choice - options: - - 'true' - - 'false' + default: '' + type: string env: PYTHON_VERSION: '3.12' @@ -261,7 +258,7 @@ jobs: release: name: Release runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') || ${{ github.event.inputs.draft == 'true' }} + if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.draft_version != '' needs: [pre-release] steps: - uses: actions/download-artifact@v4 @@ -276,12 +273,13 @@ jobs: uses: softprops/action-gh-release@v2 with: files: dist/* - draft: ${{ github.event.inputs.draft == 'true' }} + tag_name: ${{ github.event.inputs.draft_version != '' && github.event.inputs.draft_version || github.ref_name }} + draft: ${{ github.event.inputs.draft_version != '' }} prerelease: false generate_release_notes: true fail_on_unmatched_files: true - name: Publish to PyPI - if: startsWith(github.ref, 'refs/tags/') + if: github.event.inputs.draft_version == '' && startsWith(github.ref, 'refs/tags/') env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} diff --git a/README.md b/README.md index 6692e27..f497787 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [中文文档](README_CN.md) | English +[![Test](https://github.com/aliyun/aliyun-log-python-fastpb/actions/workflows/test.yml/badge.svg)](https://github.com/aliyun/aliyun-log-python-fastpb/actions/workflows/test.yml) + Fast protobuf serialization for Aliyun Log using PyO3 and quick-protobuf. ## Installation diff --git a/README_CN.md b/README_CN.md index 1146982..e35cda6 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,5 +1,7 @@ # aliyun-log-fastpb +[![Test](https://github.com/aliyun/aliyun-log-python-fastpb/actions/workflows/test.yml/badge.svg)](https://github.com/aliyun/aliyun-log-python-fastpb/actions/workflows/test.yml) + [English](README.md) | 中文文档 基于 PyO3 和 quick-protobuf 的阿里云日志高性能 protobuf 序列化库。