Skip to content

TVTComment build and release #16

TVTComment build and release

TVTComment build and release #16

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 }}