Fix: Validation #72
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: | |
| - "constructor-v*" | |
| - "servicenow-v*" | |
| pull_request: | |
| branches: ["main"] | |
| jobs: | |
| # Detect which packages changed | |
| changes: | |
| name: Detect Changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| constructor: ${{ steps.filter.outputs.constructor }} | |
| servicenow: ${{ steps.filter.outputs.servicenow }} | |
| workflows: ${{ steps.filter.outputs.workflows }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| constructor: | |
| - 'packages/constructor/**' | |
| servicenow: | |
| - 'packages/vendor/servicenow/**' | |
| workflows: | |
| - '.github/workflows/**' | |
| constructor-build-test: | |
| name: Build & Test Constructor | |
| needs: changes | |
| if: ${{ needs.changes.outputs.constructor == 'true' || needs.changes.outputs.workflows == 'true' || startsWith(github.ref, 'refs/tags/constructor-v') }} | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: packages/constructor | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| with: | |
| version: "latest" | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Install dependencies | |
| working-directory: . | |
| run: uv sync --all-groups | |
| - name: Lint (Ruff) | |
| run: uv run ruff check . | |
| - name: Run tests | |
| run: uv run pytest | |
| - name: Sync Project Version | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/tags/constructor-v* ]]; then | |
| VERSION=${GITHUB_REF_NAME#constructor-v} | |
| echo "Type: Tagged Release" | |
| else | |
| LAST_TAG=$(git tag -l 'constructor-v*' --sort=-v:refname | head -n1) | |
| if [ -z "$LAST_TAG" ]; then | |
| LAST_TAG="constructor-v0.0.0" | |
| fi | |
| VERSION="${LAST_TAG#constructor-v}-dev" | |
| echo "Type: Dev Build (Last tag: $LAST_TAG)" | |
| fi | |
| echo "Syncing pyproject.toml to version: $VERSION" | |
| uv version "$VERSION" | |
| uv version | |
| - name: Build package | |
| working-directory: . | |
| run: uv build --package scp-constructor | |
| - name: Upload Build Artifact | |
| if: startsWith(github.ref, 'refs/tags/constructor-v') | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: constructor-dist | |
| path: dist/* | |
| retention-days: 1 | |
| constructor-docker-build: | |
| name: Docker Build Constructor | |
| needs: [constructor-build-test, changes] | |
| if: ${{ needs.changes.outputs.constructor == 'true' || needs.changes.outputs.workflows == 'true' || startsWith(github.ref, 'refs/tags/constructor-v') }} | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: packages/constructor | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| if: startsWith(github.ref, 'refs/tags/constructor-v') | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository_owner }}/scp-constructor | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=match,pattern=constructor-v(.*),group=1 | |
| type=match,pattern=constructor-v(\d+\.\d+),group=1 | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: packages/constructor | |
| push: ${{ startsWith(github.ref, 'refs/tags/constructor-v') }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| constructor-publish: | |
| name: Publish Constructor | |
| needs: constructor-build-test | |
| if: startsWith(github.ref, 'refs/tags/constructor-v') | |
| runs-on: ubuntu-latest | |
| environment: pypi-constructor | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Download Build Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: constructor-dist | |
| path: dist/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/* | |
| generate_release_notes: true | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist/ | |
| servicenow-build-test: | |
| name: Build & Test ServiceNow | |
| needs: changes | |
| if: ${{ needs.changes.outputs.servicenow == 'true' || needs.changes.outputs.workflows == 'true' || startsWith(github.ref, 'refs/tags/servicenow-v') }} | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: packages/vendor/servicenow | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v3 | |
| with: | |
| version: "latest" | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Install dependencies | |
| working-directory: . | |
| run: uv sync --all-groups | |
| - name: Lint (Ruff) | |
| run: uv run ruff check . | |
| - name: Run tests | |
| run: uv run pytest | |
| - name: Sync Project Version | |
| run: | | |
| if [[ "$GITHUB_REF" == refs/tags/servicenow-v* ]]; then | |
| VERSION=${GITHUB_REF_NAME#servicenow-v} | |
| echo "Type: Tagged Release" | |
| else | |
| LAST_TAG=$(git tag -l 'servicenow-v*' --sort=-v:refname | head -n1) | |
| if [ -z "$LAST_TAG" ]; then | |
| LAST_TAG="servicenow-v0.0.0" | |
| fi | |
| VERSION="${LAST_TAG#servicenow-v}-dev" | |
| echo "Type: Dev Build (Last tag: $LAST_TAG)" | |
| fi | |
| echo "Syncing pyproject.toml to version: $VERSION" | |
| uv version "$VERSION" | |
| uv version | |
| - name: Build package | |
| working-directory: . | |
| run: uv build --package scp-servicenow | |
| - name: Upload Build Artifact | |
| if: startsWith(github.ref, 'refs/tags/servicenow-v') | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: servicenow-dist | |
| path: dist/* | |
| retention-days: 1 | |
| servicenow-publish: | |
| name: Publish ServiceNow | |
| needs: servicenow-build-test | |
| if: startsWith(github.ref, 'refs/tags/servicenow-v') | |
| runs-on: ubuntu-latest | |
| environment: pypi-servicenow | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Download Build Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: servicenow-dist | |
| path: dist/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/* | |
| generate_release_notes: true | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist/ |