diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index f2312de..d5c9a32 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -11,111 +11,117 @@ on: - main jobs: - create-dist: - runs-on: ubuntu-latest - steps: - - name: Check out the code - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.9 - - - name: Create source distribution - uses: PyO3/maturin-action@v1 - with: - command: sdist - args: > - --manifest-path Cargo.toml - --out dist - - - name: Test sdist - run: | - python -m pip install --upgrade pip - pip install --force-reinstall --verbose dist/*.tar.gz - python -c 'from polodb import PoloDB' - - - - name: Upload sdist - uses: actions/upload-artifact@v4 - with: - name: sdist - path: dist/*.tar.gz - build: - runs-on: ${{ matrix.os }} - needs: create-dist - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.9", "3.10"] - architecture: [x86_64, aarch64] # Explicitly define architectures - exclude: - - os: windows-latest - architecture: aarch64 # Skip aarch64 on W - - steps: - - name: Check out the code - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Create source distribution - uses: PyO3/maturin-action@v1 - with: - command: build - args: > - --manifest-path Cargo.toml - --profile dist-release - --out target/wheels - - - - name: Extract Version from pyproject.toml - id: get_version - run: | - VERSION=$(grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3) - echo "VERSION=$VERSION" >> $GITHUB_ENV - - - name: Print Version - run: | - echo "The current version is ${{ env.VERSION }}" - - - name: Upload Artifact with OS and Architecture Tags - uses: actions/upload-artifact@v4 - with: - name: polodb_python-${{env.VERSION}}-${{ matrix.os }}-${{ matrix.architecture }} - path: target/wheels/* - publish: - needs: build # Ensure it runs after build job - runs-on: ubuntu-latest - - steps: - - name: Check out the code - uses: actions/checkout@v4 - - - name: Download Artifacts - uses: actions/download-artifact@v4 - with: - name: dist-artifact - path: dist # Download to dist/ directory - - - name: Download Wheel Artifacts - uses: actions/download-artifact@v4 - with: - name: wheels-artifact - path: target/wheels # Download to target/wheels directory - - - name: Install Twine - run: | - python -m pip install --upgrade pip - pip install twine - - - name: Upload to PyPI with Twine - env: - TWINE_USERNAME: "__token__" - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - run: | - twine upload dist/* target/wheels/* \ No newline at end of file + create-dist: + runs-on: ubuntu-latest + steps: + - name: Check out the code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.9 + + - name: Create source distribution + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: > + --manifest-path Cargo.toml + --out dist + + - name: Test sdist + run: | + python -m pip install --upgrade pip + pip install --force-reinstall --verbose dist/*.tar.gz + python -c 'from polodb import PoloDB' + + - name: Upload sdist + uses: actions/upload-artifact@v4 + with: + name: sdist + path: dist/*.tar.gz + build: + runs-on: ${{ matrix.os }} + needs: create-dist + strategy: + matrix: + # os: [ubuntu-latest, macos-14, windows-latest] + os: [macos-14] + # python-version: ["3.9", "3.10"] + python-version: ["3.10"] + # architecture: [x86_64, aarch64] # Explicitly define architectures + architecture: [aarch64] # Explicitly define architectures + exclude: + - os: windows-latest + architecture: aarch64 + + steps: + - name: Check out the code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Create source distribution + uses: PyO3/maturin-action@v1 + with: + command: build + args: > + --manifest-path Cargo.toml + --profile dist-release + --out target/wheels + + - name: Extract Version from pyproject.toml + id: get_version + shell: bash + run: | + if [[ "$RUNNER_OS" == "Windows" ]]; then + VERSION=$(grep -m 1 version pyproject.toml | sed 's/.*version *= *"*\([^"]*\)"*/\1/') + else + VERSION=$(grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3) + fi + echo "VERSION=$VERSION" >> $GITHUB_ENV + + - name: Print Version + run: | + echo "The current version is ${{ env.VERSION }}" + + - name: Upload Artifact with OS and Architecture Tags + uses: actions/upload-artifact@v4 + with: + name: polodb_python-${{env.VERSION}}-${{ matrix.os }}-${{ matrix.architecture }}-python${{matrix.python-version}} + path: target/wheels/* + publish: + needs: build # Ensure it runs after build job + runs-on: ubuntu-latest + + steps: + - name: Check out the code + uses: actions/checkout@v4 + + # - name: Download Artifacts + # uses: actions/download-artifact@v4 + # with: + # name: sdist + # path: dist # Download to dist/ directory + + - name: Download Wheel Artifacts + uses: actions/download-artifact@v4 + with: + path: ./artifacts + + - name: Install Twine + run: | + python -m pip install --upgrade pip + pip install twine + + - name: Upload to PyPI with Twine + env: + TWINE_USERNAME: "__token__" + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + run: | + ls -R artifacts/ + twine upload artifacts/**/*.tar.gz artifacts/**/*.whl