feat: Add custom pipeline support with commit triggers and secured va… #20
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 | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test-python: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: python | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v4 | |
| - run: uv sync | |
| - name: Run tests with coverage | |
| run: uv run pytest --cov=src --cov-report=term-missing --cov-report=xml | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| if: github.ref == 'refs/heads/main' | |
| with: | |
| files: python/coverage.xml | |
| fail_ci_if_error: false | |
| test-typescript: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: typescript | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - run: npm ci | |
| - run: npm run build | |
| - run: npm test | |
| continue-on-error: true # Tests are optional for now | |
| build-python: | |
| needs: test-python | |
| if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: python | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v4 | |
| - run: uv build | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-dist | |
| path: python/dist/ | |
| build-typescript: | |
| needs: test-typescript | |
| if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: typescript | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - run: npm ci | |
| - run: npm run build | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: typescript-dist | |
| path: | | |
| typescript/dist/ | |
| typescript/package.json | |
| typescript/README.md | |
| typescript/LICENSE | |
| publish-python: | |
| needs: build-python | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: python-dist | |
| path: dist/ | |
| - name: Publish to PyPI (Trusted Publishing) | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| continue-on-error: true | |
| id: oidc | |
| - name: Publish to PyPI (Token fallback) | |
| if: steps.oidc.outcome == 'failure' | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_TOKEN }} | |
| publish-typescript: | |
| needs: build-typescript | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| environment: npm | |
| defaults: | |
| run: | |
| working-directory: typescript | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - run: npm ci | |
| - run: npm run build | |
| - name: Publish to npm | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |