ci: add GitHub Actions workflow for build, test, and release #1
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 | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| build-and-test: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET 10 SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore RunDialog.slnx | |
| - name: Build solution | |
| run: dotnet build RunDialog.slnx --configuration Release --no-restore | |
| - name: Run tests | |
| run: dotnet test RunDialog.Tests/RunDialog.Tests.csproj --configuration Release --no-build | |
| release: | |
| needs: build-and-test | |
| if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) || github.event_name == 'workflow_dispatch' | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET 10 SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Publish app for win-x64 | |
| run: | | |
| dotnet publish RunDialog.App/RunDialog.App.csproj ` | |
| -c Release ` | |
| -r win-x64 ` | |
| --self-contained true ` | |
| -p:PublishReadyToRun=true ` | |
| -p:PublishTrimmed=true ` | |
| -o ./publish/win-x64 | |
| - name: Create ZIP archive | |
| run: | | |
| Compress-Archive -Path "./publish/win-x64/*" ` | |
| -DestinationPath "./RunDialog-${{ github.ref_name || github.run_id }}-win-x64.zip" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_type == 'tag' && github.ref_name || format('manual-build-{0}', github.run_number) }} | |
| name: ${{ github.ref_type == 'tag' && github.ref_name || format('RunDialog-manual-build-{0}', github.run_number) }} | |
| files: ./RunDialog-${{ github.ref_name || github.run_id }}-win-x64.zip | |
| generate_release_notes: ${{ github.ref_type == 'tag' }} |