Skip to content

Commit

Permalink
Update pipeline
Browse files Browse the repository at this point in the history
- Update the pipeline to use a build matrix for Python versions
- Create publication job which includes multiple builds
  • Loading branch information
dcarlson-gs committed May 13, 2024
1 parent d893ed0 commit e68b9e9
Showing 1 changed file with 72 additions and 19 deletions.
91 changes: 72 additions & 19 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e68b9e9

Please sign in to comment.