From e68b9e998a90a3ea2c61992c4072fd791fa6aa66 Mon Sep 17 00:00:00 2001 From: Dennis Carlson Date: Mon, 13 May 2024 15:48:46 -0500 Subject: [PATCH] Update pipeline - Update the pipeline to use a build matrix for Python versions - Create publication job which includes multiple builds --- .github/workflows/python-package.yml | 91 ++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 19 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 447676f..4f62a55 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -10,61 +10,114 @@ on: types: [ published ] jobs: - build: + build-linux: runs-on: ubuntu-latest strategy: fail-fast: false matrix: - python-version: ["3.11"] + python-version: ["3.10", "3.11"] steps: - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: python-version: ${{ matrix.python-version }} - - name: Change directory and set up Rust Toolchain + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Set Python release + run: | + PYTHON_VERSION="${{ matrix.python-version }}" + echo "PYTHON_RELEASE=\"${PYTHON_VERSION/./}\"" >> "$GITHUB_ENV" + + - name: Lint with flake8 + run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + + - name: Set up Rust run: | cd mystiks_core rustup toolchain install stable rustup default stable rustup update - - name: Install dependencies + - name: Set Mystiks version run: | - python -m pip install --upgrade pip - python -m pip install flake8 build twine - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - - name: Lint with flake8 - run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + RELEASE_NAME="${{ github.event.release.name }}" + echo "MYSTIKS_VERSION=\"${RELEASE_NAME:1}\"" >> "$GITHUB_ENV" + if: github.event_name == 'release' && github.event.action == 'published' - name: Update Mystiks Core version working-directory: ./mystiks_core - run: | - RELEASE_NAME="${{ github.event.release.name }}" - VERSION="${RELEASE_NAME:1}" - sed -i "0,/version = \"1.0.0\"/s//version = \"${VERSION}\"/" Cargo.toml - cat Cargo.toml + run: sed -i "0,/version = \"1.0.0\"/s//version = \"${{ env.MYSTIKS_VERSION }}\"/" Cargo.toml if: github.event_name == 'release' && github.event.action == 'published' - name: Compile Mystiks Core working-directory: ./mystiks_core run: | - python_release=${{ matrix.python-version }} - python_release=${python_release/./} maturin build --release --strip - cp ./target/release/libmystiks_core.so ../mystiks/mystiks_core.cpython-${python_release}-x86_64-linux-gnu.so + mv ./target/release/libmystiks_core.so ../mystiks/mystiks_core.cpython-${{ env.PYTHON_RELEASE }}-x86_64-linux-gnu.so + + - name: Upload Mystiks Core artifact + uses: actions/upload-artifact@v4 + with: + name: mystiks_core.cpython-${{ env.PYTHON_RELEASE }}-x86_64-linux-gnu.so + path: ./mystiks/mystiks_core.cpython-${{ env.PYTHON_RELEASE }}-x86_64-linux-gnu.so + if-no-files-found: error + retention-days: 1 + + publish: + runs-on: ubuntu-latest + needs: [ build-linux ] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: 3.11 + + - name: Install Python dependencies + run: | + python -m pip install --upgrade pip + python -m pip install build + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Set Mystiks version + run: | + RELEASE_NAME="${{ github.event.release.name }}" + echo "MYSTIKS_VERSION=\"${RELEASE_NAME:1}\"" >> "$GITHUB_ENV" + if: github.event_name == 'release' && github.event.action == 'published' - name: Update Mystiks version run: | RELEASE_NAME="${{ github.event.release.name }}" VERSION="${RELEASE_NAME:1}" sed -i "0,/version='1.0.0'/s//version='${VERSION}'/" setup.py - cat setup.py if: github.event_name == 'release' && github.event.action == 'published' + - name: Download Mystiks Core (cpython-310-x86_64-linux-gnu.so) + uses: actions/download-artifact@v4 + with: + name: mystiks_core.cpython-310-x86_64-linux-gnu.so + + - name: Move Mystiks Core (cpython-310-x86_64-linux-gnu.so) + run: mv mystiks_core.cpython-310-x86_64-linux-gnu.so ./mystiks/mystiks_core.cpython-310-x86_64-linux-gnu.so + + - name: Download Mystiks Core (cpython-311-x86_64-linux-gnu.so) + uses: actions/download-artifact@v4 + with: + name: mystiks_core.cpython-311-x86_64-linux-gnu.so + + - name: Move Mystiks Core (cpython-311-x86_64-linux-gnu.so) + run: mv mystiks_core.cpython-311-x86_64-linux-gnu.so ./mystiks/mystiks_core.cpython-311-x86_64-linux-gnu.so + - name: Build the package run: python -m build