fix: 🐛 Able to handle OPTOS PSEUDOCOLOUR_ULTRAWIDEFIELD modality #20
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: Test and Release Workflow | |
on: | |
pull_request: | |
branches: | |
- "*" # Run tests on all branches for PRs | |
push: | |
branches: | |
- main # Run tests and potentially release on pushes to main | |
paths: | |
- "**/*.py" | |
- pyproject.toml | |
- poetry.lock | |
jobs: | |
run-tests: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
pip install poetry | |
poetry install | |
- name: Run tests | |
run: poetry run pytest -k 'not test_main_mapping_example_dir_relative and not test_main_mapping_example_dir and not test_process_dcm' | |
release: | |
name: Release | |
needs: run-tests | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
pip install poetry commitizen | |
poetry install | |
- name: Check if version bump is needed | |
id: check | |
continue-on-error: true | |
run: | | |
cz bump --dry-run || exit 0 | |
echo "bump=$(cz bump --dry-run 2>&1 | grep -q 'bump:' && echo 'yes' || echo 'no')" >> $GITHUB_OUTPUT | |
- name: Set up Git user | |
if: steps.check.outputs.bump == 'yes' | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Bump version | |
if: steps.check.outputs.bump == 'yes' | |
id: bump | |
run: | | |
cz bump --yes | |
echo "version=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT | |
- name: Build project | |
if: steps.check.outputs.bump == 'yes' | |
run: poetry build | |
- name: Generate Changelog | |
if: steps.check.outputs.bump == 'yes' | |
id: changelog | |
run: echo "changelog=$(cz changelog)" >> $GITHUB_OUTPUT | |
- name: Create Release | |
if: steps.check.outputs.bump == 'yes' | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ steps.bump.outputs.version }} | |
name: Release ${{ steps.bump.outputs.version }} | |
body: ${{ steps.changelog.outputs.changelog }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to PyPI | |
if: steps.check.outputs.bump == 'yes' | |
env: | |
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | |
run: | | |
poetry config pypi-token.pypi $PYPI_PASSWORD | |
poetry publish | |
- name: Push changes | |
if: steps.check.outputs.bump == 'yes' | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} |