fix(ci): build-and-release now runs on tag push; bump version to 6.2.3 #43
This file contains hidden or 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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main ] | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| lint-and-fix: | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' && !contains(github.event.head_commit.message, '[skip ci]') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install Linting Tools | |
| run: | | |
| pip install ruff | |
| - name: Run Ruff Format and Fix | |
| id: ruff | |
| run: | | |
| ruff format . | |
| ruff check . --fix | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and Push Changes | |
| if: steps.ruff.outputs.changes == 'true' | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| git commit -m "style: auto-linting and formatting [skip ci]" | |
| git push origin HEAD:${{ github.ref_name }} | |
| - name: Notify if changes were made | |
| if: steps.ruff.outputs.changes == 'true' | |
| run: | | |
| echo "Linting fixes were applied and pushed to the repository." | |
| test: | |
| needs: [lint-and-fix] | |
| if: always() && (needs.lint-and-fix.result == 'success' || needs.lint-and-fix.result == 'skipped') && !contains(github.event.head_commit.message, '[skip ci]') | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pytest pytest-cov ruff | |
| pip install -e .[all] | |
| - name: Test Core and ML | |
| run: | | |
| # Run specific critical tests | |
| python -c "import meridianalgo; print(f'MeridianAlgo {meridianalgo.__version__} loaded')" | |
| pytest tests/test_core.py tests/test_machine_learning.py -v --tb=short | |
| build-and-release: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') && (needs.test.result == 'success' || needs.test.result == 'skipped') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: | | |
| python -m build | |
| - name: Check package | |
| run: | | |
| twine check dist/* | |
| - name: Create Release and Upload Assets | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: dist/* | |
| body_path: README.md | |
| name: Release ${{ github.ref_name }} | |
| tag_name: ${{ github.ref_name }} | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| twine upload dist/* --skip-existing |