Migrate CI pipeline to Github Actions #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish CADET-RDM to PyPI | |
on: | |
push: | |
branches: | |
- master | |
- dev | |
- test_ci | |
tags: | |
- 'v*.*.*' # Trigger build stage only on version tags | |
pull_request: | |
branches: | |
- '**' # Trigger test stage on pull requests to any branch | |
jobs: | |
test-stage: | |
runs-on: ${{ matrix.os }} | |
defaults: | |
run: | |
shell: bash -l {0} | |
strategy: | |
matrix: | |
os: [ ubuntu-latest ] | |
python-version: [ "3.10", "3.11", "3.12" ] | |
include: | |
- os: windows-latest | |
python-version: "3.12" | |
- os: macos-12 | |
python-version: "3.12" | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@master | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Git LFS | |
if: runner.os == 'Linux' || runner.os == 'macOS' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y git-lfs | |
git lfs install | |
- name: Configure Git # This is required for the test suite, which checks git credentials | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Your Name" | |
- name: Set up Virtual Environment | |
run: | | |
python -m venv ../testing | |
${{ runner.os == 'Windows' && 'source ../testing/Scripts/activate' || 'source ../testing/bin/activate' }} | |
- name: Install Dependencies | |
run: | | |
pip install -U pytest setuptools | |
pip install .[testing] | |
- name: Verify Installation | |
run: | | |
pip list | |
ls -l | |
- name: Run Tests | |
run: | | |
pytest tests -m "not server_api" | |
build-release: | |
name: Build and Upload Release | |
runs-on: ubuntu-latest | |
needs: test-stage # Ensure this job runs only after test-stage succeeds | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.12 | |
- name: Install Build Tools | |
run: | | |
pip install -U build twine | |
- name: Build the Package | |
run: | | |
python -m build | |
- name: Upload to PyPI | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }} | |
run: | | |
python -m twine upload dist/* |