diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000000..d6e8098c7be --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,63 @@ +name: Build & Publish .NET App + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + # ----------------- 1️⃣ BUILD JOB ----------------- + build: + name: Build & Test + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + - name: Restore dependencies + run: dotnet restore + + - name: Build project + run: dotnet build --configuration Release --no-restore + + - name: Run tests + run: dotnet test --configuration Release --no-build --verbosity normal + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: build-output + path: | + **/bin/Release/net8.0/ + !**/*.pdb # Optional: exclude debug files + + # ----------------- 2️⃣ PUBLISH JOB ----------------- + publish: + name: Publish App + runs-on: ubuntu-latest + needs: build # ✅ waits for build job to succeed first + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: build-output + + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + - name: Publish project + run: dotnet publish ./MyProject.csproj --configuration Release --output ./publish + + - name: Upload publish artifact + uses: actions/upload-artifact@v4 + with: + name: publish-output + path: ./publish