forked from silane/TVTComment
-
Notifications
You must be signed in to change notification settings - Fork 6
153 lines (132 loc) · 5.08 KB
/
AutoBuildAndRelease.yml
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
146
147
148
149
150
151
152
153
name: TVTComment build and release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
manual:
description: 'Please type version. Ex:"v*"'
required: true
default: ""
jobs:
exe-build:
name: TVTComment.exe build
runs-on: windows-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Include CoreTweet Nuget
run: nuget sources add -name CoreTweetSource -source ${{ github.workspace }}\CoreTweetNuget
- name: Replace id & secret
shell: powershell
run: |
$data=Get-Content TVTComment/ViewModels/SettingsWindowViewModel.cs | % { $_ -replace 'secrets\["Annict:ClientId"\]','"${{ secrets.CLIENT_ID }}"' }
$data | Out-File TVTComment/ViewModels/SettingsWindowViewModel.cs
$data=Get-Content TVTComment/ViewModels/SettingsWindowViewModel.cs | % { $_ -replace 'secrets\["Annict:ClientSecret"\]','"${{ secrets.CLIENT_SECRET }}"' }
$data | Out-File TVTComment/ViewModels/SettingsWindowViewModel.cs
- name: Build (TVTComment.exe)
run: dotnet publish -m -c Release /p:PublishProfile="TVTComment/Properties/PublishProfiles/ReleaseProfile.pubxml"
- name: Copy asset (TVTComment.exe)
shell: powershell
run: |
New-Item -Path Asset -ItemType Directory
New-Item -Path Asset/misc -ItemType Directory
Copy-Item -Path TVTComment/bin/Release/net8.0-windows/publish/TvtComment.exe -Destination Asset/
Copy-Item -Path TVTComment/Data/* -Destination Asset/
Copy-Item -Path CHANGELOG.md -Destination Asset/misc/CHANGELOG.txt
Copy-Item -Path LICENSE -Destination Asset/misc/LICENSE.txt
Copy-Item -Path THIRDPARTY_LICENSE -Destination Asset/misc/THIRDPARTY_LICENSE.txt
Copy-Item -Path README.md -Destination "Asset/misc/README edit noriokun4649.txt"
- name: Before CHANGELOG get
shell: powershell
run: |
$env:before = git log -2 --reverse --format='%H' CHANGELOG.md
$env:before = $env:before.Substring(0,40)
git checkout $env:before CHANGELOG.md
Copy-Item -Path CHANGELOG.md -Destination Asset/misc/OLDCHANGELOG.txt
- name: Upload asset to Artifacts (TVTComment.exe)
uses: actions/upload-artifact@v4
with:
name: TvtComment
if-no-files-found: error
path: Asset/
tvtp-build:
name: tvtcomment.tvtp build
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
platform:
- x64
- Win32
steps:
- name: checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Build (tvtcomment.tvtp)
run: msbuild Viewer/Viewer.vcxproj -m /p:Configuration="Release" /p:Platform="${{ matrix.platform }}" /p:CodePage=932
- name: Copy asset (tvtcomment.tvtp)
shell: powershell
run: |
New-Item -Path Asset -ItemType Directory
Copy-Item -Path Viewer/${{ matrix.platform }}/Release/TvtComment.tvtp -Destination Asset/
- name: Upload asset to Artifacts (tvtcomment.tvtp)
uses: actions/upload-artifact@v4
with:
name: TvtComment_${{ matrix.platform }}
if-no-files-found: error
path: Asset/
release:
needs:
- exe-build
- tvtp-build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: Asset/
- name: Get version from tag
id: ver
if: github.event.inputs.manual == ''
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- name: Get version from input
if: steps.ver.conclusion == 'skipped' && github.event.inputs.manual != ''
run: echo "RELEASE_VERSION=${{github.event.inputs.manual}}" >> $GITHUB_ENV
- name: Get CHANGELOG
run: |
echo 'CHANGELOG<<EOF' >> $GITHUB_ENV
diff -u --strip-trailing-cr Asset/TvtComment/misc/OLDCHANGELOG.txt Asset/TvtComment/misc/CHANGELOG.txt | grep ^+ | grep -v ^+++ | sed s/^+// >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Move misc files
run: |
mv Asset/TvtComment/misc/* Asset/
rm Asset/OLDCHANGELOG.txt
rmdir Asset/TvtComment/misc
- name: Repack assets
run: |
cd Asset
7z a -r ../TvtComment_v${{ env.RELEASE_VERSION }}.zip *
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.RELEASE_VERSION }}
name: Release v${{ env.RELEASE_VERSION }}
body: ${{ env.CHANGELOG }}
draft: false
prerelease: false
files: TvtComment_v${{ env.RELEASE_VERSION }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}