|
| 1 | +name: "Deploy Release" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: # manual trigger |
| 5 | + |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + runs-on: windows-latest |
| 9 | + |
| 10 | + env: |
| 11 | + Solution: "src/CleanMyPosts.sln" |
| 12 | + UI_Project: "src/UI/UI.csproj" |
| 13 | + UnitTest_Project: "src/UnitTests/UnitTests.csproj" |
| 14 | + IntegrationTest_Project: "src/IntegrationTests/IntegrationTests.csproj" |
| 15 | + Installer_Script: "installer/Installer.iss" |
| 16 | + FORCE_COLOR: "true" |
| 17 | + DOTNET_LOGGING__CONSOLE__COLORBEHAVIOR: Enabled |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 # Important to fetch full history for git tag and branches |
| 24 | + |
| 25 | + - name: Install .NET |
| 26 | + uses: actions/setup-dotnet@v4 |
| 27 | + with: |
| 28 | + dotnet-version: 9.x |
| 29 | + |
| 30 | + - name: Restore |
| 31 | + run: dotnet restore "${{ env.Solution }}" |
| 32 | + |
| 33 | + - name: Build |
| 34 | + run: dotnet build "${{ env.Solution }}" --configuration Release --no-restore |
| 35 | + |
| 36 | + - name: Run Unit Tests |
| 37 | + run: dotnet test "${{ env.UnitTest_Project }}" --configuration Release --logger "console;verbosity=detailed" --filter "TestCategory!=Long-Running" |
| 38 | + |
| 39 | + - name: Run Integration Tests |
| 40 | + run: dotnet test "${{ env.IntegrationTest_Project }}" --configuration Release --logger "console;verbosity=detailed" |
| 41 | + |
| 42 | + - name: Extract Version |
| 43 | + id: get_version |
| 44 | + shell: pwsh |
| 45 | + run: | |
| 46 | + $content = Get-Content "${{ env.UI_Project }}" |
| 47 | + if ($content -match '<Version>(.+)</Version>') { |
| 48 | + $version = $matches[1] |
| 49 | + echo "VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 50 | + } else { |
| 51 | + throw "Version not found in project file" |
| 52 | + } |
| 53 | +
|
| 54 | + - name: Publish Single EXE |
| 55 | + run: | |
| 56 | + dotnet publish "${{ env.UI_Project }}" -c Release -r win-x64 --self-contained true ` |
| 57 | + /p:PublishSingleFile=true ` |
| 58 | + /p:IncludeAllContentForSelfExtract=true ` |
| 59 | + /p:EnableCompressionInSingleFile=true ` |
| 60 | + -o artifacts/single-exe |
| 61 | +
|
| 62 | + - name: Install Inno Setup |
| 63 | + run: choco install innosetup --yes |
| 64 | + |
| 65 | + - name: Build Setup EXE |
| 66 | + run: | |
| 67 | + iscc "/DMyAppVersion=${{ env.VERSION }}" "/DMyAppExePath=artifacts\\single-exe\\*" "${{ env.Installer_Script }}" |
| 68 | +
|
| 69 | + - name: Copy Setup EXE to Artifacts |
| 70 | + run: | |
| 71 | + mkdir -p artifacts/setup |
| 72 | + copy installer\Output\CleanMyPosts-Setup-${{ env.VERSION }}.exe artifacts\setup\ |
| 73 | +
|
| 74 | + - name: Rename Standalone EXE for Release |
| 75 | + run: | |
| 76 | + Rename-Item "artifacts/single-exe/CleanMyPosts.exe" "artifacts/single-exe/CleanMyPosts-standalone.exe" |
| 77 | +
|
| 78 | + - name: Generate update.xml |
| 79 | + shell: pwsh |
| 80 | + run: | |
| 81 | + $version = "${{ env.VERSION }}" |
| 82 | + $repo = "${{ github.repository }}" |
| 83 | + $baseUrl = "https://github.com/$repo/releases/download/v$version" |
| 84 | + $installerUrl = "$baseUrl/CleanMyPosts-Setup-$version.exe" |
| 85 | + $changelogUrl = "https://github.com/$repo/releases/tag/v$version" |
| 86 | + $xmlContent = @" |
| 87 | + <?xml version='1.0' encoding='utf-8'?> |
| 88 | + <updates> |
| 89 | + <application> |
| 90 | + <name>CleanMyPosts</name> |
| 91 | + <version>$version</version> |
| 92 | + <url>$installerUrl</url> |
| 93 | + <changelog>$changelogUrl</changelog> |
| 94 | + </application> |
| 95 | + </updates> |
| 96 | + "@ |
| 97 | + $xmlContent | Set-Content -Path "artifacts/update.xml" -Encoding UTF8 |
| 98 | +
|
| 99 | + - name: Configure Git Credentials |
| 100 | + run: | |
| 101 | + echo "https://${{ secrets.GH_APIKEY }}@github.com" > $env:USERPROFILE\.git-credentials |
| 102 | + git config --global credential.helper store |
| 103 | + git config --global user.name "github-actions" |
| 104 | + git config --global user.email "[email protected]" |
| 105 | +
|
| 106 | + - name: Push update.xml to update-feed branch |
| 107 | + run: | |
| 108 | + git fetch origin update-feed || echo "No update-feed branch yet" |
| 109 | + if git show-ref --verify --quiet refs/heads/update-feed; then |
| 110 | + git checkout update-feed |
| 111 | + else |
| 112 | + git checkout --orphan update-feed |
| 113 | + git rm -rf . |
| 114 | + fi |
| 115 | +
|
| 116 | + cp artifacts/update.xml update.xml |
| 117 | + git add update.xml |
| 118 | +
|
| 119 | + if git diff --cached --quiet; then |
| 120 | + echo "No changes in update.xml; skipping commit" |
| 121 | + else |
| 122 | + git commit -m "Update appcast for version ${{ env.VERSION }}" |
| 123 | + git push origin update-feed --force |
| 124 | + fi |
| 125 | +
|
| 126 | + - name: Create Git Tag |
| 127 | + run: | |
| 128 | + git tag -a "v${{ env.VERSION }}" -m "Release v${{ env.VERSION }}" |
| 129 | + git push origin "v${{ env.VERSION }}" |
| 130 | +
|
| 131 | + - name: Create GitHub Release |
| 132 | + uses: softprops/action-gh-release@v1 |
| 133 | + with: |
| 134 | + tag_name: "v${{ env.VERSION }}" |
| 135 | + name: "CleanMyPosts ${{ env.VERSION }}" |
| 136 | + body_path: ./release-notes/v${{ env.VERSION }}.md |
| 137 | + files: | |
| 138 | + artifacts/single-exe/CleanMyPosts-standalone.exe |
| 139 | + artifacts/setup/CleanMyPosts-Setup-${{ env.VERSION }}.exe |
| 140 | + artifacts/update.xml |
| 141 | + env: |
| 142 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments