run dump again #5
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
| # GitHub Actions Workflow: Build and Create Release | |
| # Triggers on every push to any branch | |
| # Creates self-contained executables for all major desktop platforms | |
| # Publishes a full GitHub release (never pre-release) with all binaries | |
| # | |
| # Supported platforms: | |
| # - Windows: x64, ARM64 | |
| # - macOS: x64 (Intel), ARM64 (Apple Silicon) | |
| # - Linux: x64, ARM64 | |
| # | |
| # Design Philosophy: | |
| # - Avoid high-level GitHub Actions abstractions where possible | |
| # - Use shell commands directly instead of specialized actions | |
| # - Only use actions/checkout, actions/upload-artifact, actions/download-artifact | |
| # (these are fundamental and have no simpler alternative) | |
| # - Use GitHub CLI (gh) for release creation instead of specialized release actions | |
| # - Install .NET manually using official install scripts | |
| name: Build and Release | |
| on: | |
| push: | |
| branches: | |
| - '**' # All branches | |
| permissions: | |
| contents: write # Required to create releases and upload assets | |
| env: | |
| DOTNET_NOLOGO: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| PROJECT_PATH: src/NetworkMonitor.Console/NetworkMonitor.Console.csproj | |
| SOLUTION_PATH: src/NetworkMonitor.slnx | |
| jobs: | |
| # ========================================================================== | |
| # Build binaries for each platform | |
| # Each platform builds on its native runner for best compatibility | |
| # ========================================================================== | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Windows x64 | |
| - os: windows-latest | |
| rid: win-x64 | |
| artifact-name: network-monitor-win-x64 | |
| archive-type: zip | |
| # Windows ARM64 (cross-compile from x64) | |
| - os: windows-latest | |
| rid: win-arm64 | |
| artifact-name: network-monitor-win-arm64 | |
| archive-type: zip | |
| # macOS x64 (Intel) - uses macos-latest | |
| - os: macos-latest | |
| rid: osx-x64 | |
| artifact-name: network-monitor-osx-x64 | |
| archive-type: tar | |
| # macOS ARM64 (Apple Silicon) - uses macos-latest | |
| - os: macos-latest | |
| rid: osx-arm64 | |
| artifact-name: network-monitor-osx-arm64 | |
| archive-type: tar | |
| # Linux x64 | |
| - os: ubuntu-latest | |
| rid: linux-x64 | |
| artifact-name: network-monitor-linux-x64 | |
| archive-type: tar | |
| # Linux ARM64 (cross-compile from x64) | |
| - os: ubuntu-latest | |
| rid: linux-arm64 | |
| artifact-name: network-monitor-linux-arm64 | |
| archive-type: tar | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| # Checkout - fundamental action, no simpler alternative exists | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Install .NET manually using official Microsoft install scripts | |
| # This avoids the actions/setup-dotnet abstraction | |
| - name: Install .NET 10 (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| curl -sSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh | |
| chmod +x dotnet-install.sh | |
| ./dotnet-install.sh --channel 10.0 --quality preview --install-dir "$HOME/.dotnet" | |
| echo "$HOME/.dotnet" >> $GITHUB_PATH | |
| echo "DOTNET_ROOT=$HOME/.dotnet" >> $GITHUB_ENV | |
| - name: Install .NET 10 (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| Invoke-WebRequest -Uri https://dot.net/v1/dotnet-install.ps1 -OutFile dotnet-install.ps1 | |
| ./dotnet-install.ps1 -Channel 10.0 -Quality preview -InstallDir "$env:USERPROFILE\.dotnet" | |
| echo "$env:USERPROFILE\.dotnet" | Out-File -FilePath $env:GITHUB_PATH -Append | |
| echo "DOTNET_ROOT=$env:USERPROFILE\.dotnet" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Verify .NET installation | |
| shell: bash | |
| run: | | |
| dotnet --info | |
| - name: Restore dependencies | |
| shell: bash | |
| run: | | |
| dotnet restore ${{ env.SOLUTION_PATH }} | |
| - name: Publish self-contained binary | |
| shell: bash | |
| run: | | |
| dotnet publish ${{ env.PROJECT_PATH }} \ | |
| --configuration Release \ | |
| --runtime ${{ matrix.rid }} \ | |
| --self-contained true \ | |
| -p:PublishSingleFile=true \ | |
| -p:PublishTrimmed=false \ | |
| -p:IncludeNativeLibrariesForSelfExtract=true \ | |
| -p:DebugType=None \ | |
| -p:DebugSymbols=false \ | |
| --output ./publish/${{ matrix.rid }} | |
| - name: List published files | |
| shell: bash | |
| run: | | |
| echo "Published files for ${{ matrix.rid }}:" | |
| ls -la ./publish/${{ matrix.rid }}/ | |
| - name: Create tar.gz archive (Unix) | |
| if: matrix.archive-type == 'tar' | |
| shell: bash | |
| run: | | |
| cd publish | |
| tar -czvf ../${{ matrix.artifact-name }}.tar.gz ${{ matrix.rid }} | |
| cd .. | |
| echo "Created archive:" | |
| ls -la ${{ matrix.artifact-name }}.tar.gz | |
| - name: Create zip archive (Windows) | |
| if: matrix.archive-type == 'zip' | |
| shell: pwsh | |
| run: | | |
| Compress-Archive -Path "publish\${{ matrix.rid }}\*" -DestinationPath "${{ matrix.artifact-name }}.zip" | |
| Write-Host "Created archive:" | |
| Get-ChildItem "${{ matrix.artifact-name }}.zip" | |
| # Upload artifact - fundamental action for passing files between jobs | |
| # No simpler alternative exists in GitHub Actions | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact-name }} | |
| path: | | |
| ${{ matrix.artifact-name }}.tar.gz | |
| ${{ matrix.artifact-name }}.zip | |
| retention-days: 1 | |
| if-no-files-found: error | |
| # ========================================================================== | |
| # Create GitHub Release with all binaries | |
| # Uses GitHub CLI (gh) instead of specialized release actions | |
| # ========================================================================== | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 50 # Get some history for release notes | |
| # Download artifacts - fundamental action for receiving files from other jobs | |
| - name: Download all build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./artifacts | |
| - name: Prepare release assets | |
| shell: bash | |
| run: | | |
| mkdir -p ./release-assets | |
| # Move all archives to a flat directory | |
| find ./artifacts -type f \( -name "*.zip" -o -name "*.tar.gz" \) -exec mv {} ./release-assets/ \; | |
| echo "=== Release Assets ===" | |
| ls -la ./release-assets/ | |
| - name: Generate version string | |
| id: version | |
| shell: bash | |
| run: | | |
| # Version format: v1.0.YYYYMMDD.HHMMSS | |
| # This ensures unique, sortable versions for every push | |
| VERSION="v1.0.$(date -u +%Y%m%d.%H%M%S)" | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "Generated version: ${VERSION}" | |
| - name: Generate checksums | |
| shell: bash | |
| run: | | |
| cd ./release-assets | |
| sha256sum * > SHA256SUMS.txt | |
| echo "=== Checksums ===" | |
| cat SHA256SUMS.txt | |
| - name: Generate release notes | |
| shell: bash | |
| run: | | |
| COMMIT_MSG=$(git log -1 --pretty=format:"%s") | |
| COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an") | |
| COMMIT_DATE=$(git log -1 --pretty=format:"%ai") | |
| cat > release-notes.md << 'NOTES_EOF' | |
| ## Network Monitor Release | |
| **Branch:** `${{ github.ref_name }}` | |
| **Commit:** `${{ github.sha }}` | |
| **Author:** COMMIT_AUTHOR_PLACEHOLDER | |
| **Date:** COMMIT_DATE_PLACEHOLDER | |
| ### Commit Message | |
| COMMIT_MSG_PLACEHOLDER | |
| --- | |
| ### Downloads | |
| | Platform | Architecture | Filename | | |
| |----------|--------------|----------| | |
| | Windows | x64 | `network-monitor-win-x64.zip` | | |
| | Windows | ARM64 | `network-monitor-win-arm64.zip` | | |
| | macOS | x64 (Intel) | `network-monitor-osx-x64.tar.gz` | | |
| | macOS | ARM64 (Apple Silicon) | `network-monitor-osx-arm64.tar.gz` | | |
| | Linux | x64 | `network-monitor-linux-x64.tar.gz` | | |
| | Linux | ARM64 | `network-monitor-linux-arm64.tar.gz` | | |
| ### Installation | |
| **Windows:** | |
| ```powershell | |
| # Extract and run | |
| Expand-Archive network-monitor-win-x64.zip -DestinationPath . | |
| .\win-x64\NetworkMonitor.Console.exe | |
| ``` | |
| **macOS / Linux:** | |
| ```bash | |
| # Extract and run | |
| tar -xzf network-monitor-linux-x64.tar.gz | |
| ./linux-x64/NetworkMonitor.Console | |
| ``` | |
| ### SHA256 Checksums | |
| ``` | |
| CHECKSUMS_PLACEHOLDER | |
| ``` | |
| NOTES_EOF | |
| # Replace placeholders with actual values | |
| sed -i "s/COMMIT_AUTHOR_PLACEHOLDER/${COMMIT_AUTHOR}/" release-notes.md | |
| sed -i "s/COMMIT_DATE_PLACEHOLDER/${COMMIT_DATE}/" release-notes.md | |
| sed -i "s/COMMIT_MSG_PLACEHOLDER/${COMMIT_MSG}/" release-notes.md | |
| # Insert checksums | |
| CHECKSUMS=$(cat ./release-assets/SHA256SUMS.txt) | |
| # Use awk for multi-line replacement | |
| awk -v checksums="$CHECKSUMS" '{gsub(/CHECKSUMS_PLACEHOLDER/, checksums); print}' release-notes.md > release-notes-final.md | |
| mv release-notes-final.md release-notes.md | |
| echo "=== Release Notes ===" | |
| cat release-notes.md | |
| - name: Create Git tag | |
| shell: bash | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "${{ steps.version.outputs.version }}" -m "Release ${{ steps.version.outputs.version }}" | |
| git push origin "${{ steps.version.outputs.version }}" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Release | |
| shell: bash | |
| run: | | |
| # Using GitHub CLI (pre-installed) instead of a release action | |
| # --latest marks this as the latest release (not pre-release) | |
| gh release create "${{ steps.version.outputs.version }}" \ | |
| --title "Release ${{ steps.version.outputs.version }}" \ | |
| --notes-file release-notes.md \ | |
| --latest \ | |
| ./release-assets/*.zip \ | |
| ./release-assets/*.tar.gz \ | |
| ./release-assets/SHA256SUMS.txt | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Output release summary | |
| shell: bash | |
| run: | | |
| echo "## ✅ Release Created Successfully" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Version:** \`${{ steps.version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Release URL:** https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Assets" >> $GITHUB_STEP_SUMMARY | |
| for file in ./release-assets/*; do | |
| filename=$(basename "$file") | |
| size=$(ls -lh "$file" | awk '{print $5}') | |
| echo "- \`${filename}\` (${size})" >> $GITHUB_STEP_SUMMARY | |
| done |