diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..16acbfa --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,52 @@ +name: Publish and Release on Commit + +on: + push: + branches: + - main # Trigger workflow on push to the main branch; change this as needed + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # Step 1: Checkout the code + - name: Checkout code + uses: actions/checkout@v3 + + # Step 2: Set up .NET + - name: Set up .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '7.0.x' # Use the appropriate version + + # Step 3: Restore dependencies + - name: Restore dependencies + run: dotnet restore + + # Step 4: Publish the project + - name: Publish the application + run: dotnet publish -c Release -o ./publish # Output to ./publish folder + + # Step 5: Create a release + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.sha }} + release_name: Release ${{ github.sha }} + draft: false + prerelease: false + + # Step 6: Upload published files to release + - name: Upload .NET Publish Artifacts + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./publish + asset_name: published_app.zip + asset_content_type: application/zip