Enable NuGet lock file for reproducible builds (MINOR) #10
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: Build and Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '**.cs' | |
| - '**.csproj' | |
| - '**.xaml' | |
| - '**.sln' | |
| - 'app.manifest' | |
| - 'Resources/**' | |
| - '.github/workflows/build-release.yml' | |
| tags: | |
| - 'v*.*.*' # Only for creating releases, not building | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - '**.cs' | |
| - '**.csproj' | |
| - '**.xaml' | |
| - '**.sln' | |
| - 'app.manifest' | |
| - 'Resources/**' | |
| workflow_dispatch: # Allow manual trigger | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| if: github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/') | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Required for semantic versioning to access git history | |
| - name: Calculate semantic version | |
| id: version | |
| uses: paulhatch/semantic-version@v5.4.0 | |
| with: | |
| tag_prefix: "v" | |
| major_pattern: "(MAJOR)" | |
| minor_pattern: "(MINOR)" | |
| version_format: "${major}.${minor}.${patch}" | |
| bump_each_commit: false | |
| search_commit_body: false | |
| enable_prerelease_mode: false | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| cache: true | |
| cache-dependency-path: '**/packages.lock.json' | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Restore dependencies | |
| run: dotnet restore ContextMenuEditor.csproj | |
| - name: Cache build output | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| **/bin | |
| **/obj | |
| key: ${{ runner.os }}-build-${{ hashFiles('**/*.cs', '**/*.csproj', '**/*.xaml') }}-${{ steps.version.outputs.version }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ hashFiles('**/*.cs', '**/*.csproj', '**/*.xaml') }}- | |
| ${{ runner.os }}-build- | |
| - name: Build application | |
| run: dotnet build ContextMenuEditor.csproj --configuration Release --no-restore /p:Version=${{ steps.version.outputs.version }} | |
| - name: Publish application | |
| run: dotnet publish ContextMenuEditor.csproj --configuration Release --runtime win-x64 --self-contained true --output ./publish /p:Version=${{ steps.version.outputs.version }} | |
| - name: Copy README to publish folder | |
| run: Copy-Item README.md ./publish/ | |
| shell: pwsh | |
| - name: Create release package | |
| run: | | |
| $version = "${{ steps.version.outputs.version }}" | |
| $zipName = "ContextMenuEditor-v$version-win-x64.zip" | |
| Compress-Archive -Path ./publish/* -DestinationPath $zipName | |
| echo "ZIP_NAME=$zipName" >> $env:GITHUB_ENV | |
| echo "VERSION=v$version" >> $env:GITHUB_ENV | |
| shell: pwsh | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ContextMenuEditor-${{ env.VERSION }} | |
| path: ${{ env.ZIP_NAME }} | |
| retention-days: 90 | |
| - name: Create and push version tag | |
| if: github.ref == 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') | |
| run: | | |
| $version = "v${{ steps.version.outputs.version }}" | |
| $isTagged = "${{ steps.version.outputs.is_tagged }}" | |
| if ($isTagged -eq "false") { | |
| Write-Host "Creating and pushing tag: $version" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a $version -m "Release $version" | |
| git push origin $version | |
| } else { | |
| Write-Host "Commit already tagged, skipping tag creation" | |
| } | |
| shell: pwsh | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: windows-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| $tagName = "${{ github.ref_name }}" | |
| $version = $tagName -replace '^v', '' | |
| echo "VERSION=$version" >> $env:GITHUB_ENV | |
| echo "TAG_NAME=$tagName" >> $env:GITHUB_ENV | |
| shell: pwsh | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| cache: true | |
| cache-dependency-path: '**/packages.lock.json' | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Restore dependencies | |
| run: dotnet restore ContextMenuEditor.csproj | |
| - name: Build application | |
| run: dotnet build ContextMenuEditor.csproj --configuration Release --no-restore /p:Version=${{ env.VERSION }} | |
| - name: Publish application | |
| run: dotnet publish ContextMenuEditor.csproj --configuration Release --runtime win-x64 --self-contained true --output ./publish /p:Version=${{ env.VERSION }} | |
| - name: Copy README to publish folder | |
| run: Copy-Item README.md ./publish/ | |
| shell: pwsh | |
| - name: Create release package | |
| run: | | |
| $version = "${{ env.VERSION }}" | |
| $zipName = "ContextMenuEditor-v$version-win-x64.zip" | |
| Compress-Archive -Path ./publish/* -DestinationPath $zipName | |
| echo "ZIP_NAME=$zipName" >> $env:GITHUB_ENV | |
| shell: pwsh | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: ${{ env.ZIP_NAME }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| name: Context Menu Editor v${{ env.VERSION }} | |
| body: | | |
| ## Context Menu Editor v${{ env.VERSION }} | |
| **Semantic Version**: `${{ env.VERSION }}` | |
| ### Installation | |
| 1. Download the ZIP file below | |
| 2. Extract all files to a folder | |
| 3. Right-click `ContextMenuEditor.exe` and select "Run as administrator" | |
| ### Requirements | |
| - Windows 10/11 (build 17763+) | |
| - No .NET installation required (self-contained) | |
| ### Features | |
| - View and manage Windows context menu items | |
| - Enable/disable context menu entries | |
| - Delete unwanted context menu items | |
| - Backup registry entries to .REG file | |
| - Dark/Light theme support | |
| ⚠️ **Important**: This application requires administrator privileges to modify registry entries. | |
| ### Commit Messages Guide | |
| To control version increments in your commits, use these markers: | |
| - `(MAJOR)` in commit message → Breaking changes (e.g., v1.0.0 → v2.0.0) | |
| - `(MINOR)` in commit message → New features (e.g., v1.0.0 → v1.1.0) | |
| - No marker → Bug fixes/patches (e.g., v1.0.0 → v1.0.1) | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |