|
| 1 | +# Reusable workflow for building the solution. |
| 2 | +# |
| 3 | +# This workflow is designed to be called by other workflows to avoid |
| 4 | +# redundant compilation. It builds the solution and uploads the build |
| 5 | +# artifacts for downstream jobs to consume. |
| 6 | +# |
| 7 | +# Usage in other workflows: |
| 8 | +# jobs: |
| 9 | +# build: |
| 10 | +# uses: ./.github/workflows/build.yml |
| 11 | +# with: |
| 12 | +# configuration: Release |
| 13 | +# |
| 14 | +# dependent-job: |
| 15 | +# needs: build |
| 16 | +# steps: |
| 17 | +# - uses: actions/download-artifact@v4 |
| 18 | +# with: |
| 19 | +# name: build-output-Release |
| 20 | + |
| 21 | +name: Build |
| 22 | + |
| 23 | +on: |
| 24 | + # Allow this workflow to be called by other workflows |
| 25 | + workflow_call: |
| 26 | + inputs: |
| 27 | + configuration: |
| 28 | + description: 'Build configuration (Debug or Release)' |
| 29 | + required: false |
| 30 | + default: 'Debug' |
| 31 | + type: string |
| 32 | + upload_artifacts: |
| 33 | + description: 'Whether to upload build artifacts' |
| 34 | + required: false |
| 35 | + default: true |
| 36 | + type: boolean |
| 37 | + |
| 38 | + # Also allow standalone execution for testing |
| 39 | + workflow_dispatch: |
| 40 | + inputs: |
| 41 | + configuration: |
| 42 | + description: 'Build configuration' |
| 43 | + required: false |
| 44 | + default: 'Debug' |
| 45 | + type: choice |
| 46 | + options: |
| 47 | + - Debug |
| 48 | + - Release |
| 49 | + |
| 50 | +# Restrict default permissions for security |
| 51 | +permissions: |
| 52 | + contents: read |
| 53 | + |
| 54 | +jobs: |
| 55 | + build: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + timeout-minutes: 15 |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Checkout repository |
| 61 | + uses: actions/checkout@v4 |
| 62 | + with: |
| 63 | + fetch-depth: 0 # Full history for version calculation |
| 64 | + |
| 65 | + - name: Setup .NET |
| 66 | + uses: actions/setup-dotnet@v4 |
| 67 | + with: |
| 68 | + dotnet-version: | |
| 69 | + 8.0.x |
| 70 | + 9.0.x |
| 71 | + 10.0.x |
| 72 | +
|
| 73 | + - name: Restore dependencies |
| 74 | + run: dotnet restore EfCore.StorageEstimator.slnx |
| 75 | + |
| 76 | + - name: Build solution |
| 77 | + # Build the entire solution with the specified configuration |
| 78 | + run: dotnet build EfCore.StorageEstimator.slnx --configuration ${{ inputs.configuration }} --no-restore |
| 79 | + |
| 80 | + - name: Upload build artifacts |
| 81 | + # Upload the build output for downstream jobs to consume |
| 82 | + # This avoids the need to rebuild in dependent workflows |
| 83 | + if: ${{ inputs.upload_artifacts }} |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: build-output-${{ inputs.configuration }} |
| 87 | + path: | |
| 88 | + src/**/bin/${{ inputs.configuration }} |
| 89 | + src/**/obj/${{ inputs.configuration }} |
| 90 | + tests/**/bin/${{ inputs.configuration }} |
| 91 | + tests/**/obj/${{ inputs.configuration }} |
| 92 | + samples/**/bin/${{ inputs.configuration }} |
| 93 | + samples/**/obj/${{ inputs.configuration }} |
| 94 | + retention-days: 1 |
0 commit comments