-
Notifications
You must be signed in to change notification settings - Fork 3
145 lines (120 loc) · 4.85 KB
/
deploy-release.yml
File metadata and controls
145 lines (120 loc) · 4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: "Deploy Release"
on:
workflow_dispatch: # manual trigger
permissions:
contents: write
pull-requests: write
checks: write
id-token: write
jobs:
build:
runs-on: windows-latest
env:
Solution: "src/CleanMyPosts.slnx"
UI_Project: "src/CleanMyPosts/CleanMyPosts.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: 10.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://raw.githubusercontent.com/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/create-github-app-token@v2.0.5
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 }}