Skip to content

Commit

Permalink
Windows向けビルドルールを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
TetsuOtter committed Sep 23, 2024
1 parent 5b5ed47 commit 2b3d6d2
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 0 deletions.
189 changes: 189 additions & 0 deletions .github/workflows/cd-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ env:
TARGET_FRAMEWORK_MAC: net8.0-maccatalyst
TARGET_RUNTIME_MAC: osx
TARGET_FRAMEWORK_ANDROID: net8.0-android
TARGET_FRAMEWORK_WIN: net8.0-windows10.0.19041.0
TARGET_RUNTIME_WINX64: win10-x64
TARGET_RUNTIME_WINX86: win10-x86
OUTPUT_DIR: ./out
IPA_PATH: ./out/TRViS.ipa
PKG_PATH: ./out/TRViS.pkg
AAB_PATH: ./out/dev.t0r.trvis-Signed.aab
APK_PATH: ./out/dev.t0r.trvis-Signed.apk
ASSET_NAME_WIN_X64: TRViS-win-x64
ASSET_NAME_WIN_X86: TRViS-win-x86
ASSET_NAME_WIN_X64_SELF_CONTAINED: TRViS-win-x64-self-contained
ASSET_NAME_WIN_X86_SELF_CONTAINED: TRViS-win-x86-self-contained
SDK_VERSION: '8.0.401'
APP_CENTER_SECRETS_FILE_NAME: ./TRViS/AppCenterSecrets.cs
IOS_DSYM_PATH: ./TRViS/bin/Release/net8.0-ios/ios-arm64
Expand Down Expand Up @@ -467,6 +474,148 @@ jobs:
if: always() && steps.import-code-sign-cert.conclusion == 'success'
run: /usr/bin/security delete-keychain ${{ steps.gen-keychain-name.outputs.keychain-name }}.keychain

build-windows:
if: |
!failure()
&& !cancelled()
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.draft == false
)
runs-on: windows-latest
timeout-minutes: 30
needs:
- get-version

steps:
- uses: actions/checkout@v4

- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.SDK_VERSION }}
- name: Install dotnet workloads
run: dotnet workload install maui-windows

- name: Install dependencies
run: dotnet restore ${{ env.CSPROJ_PATH }}

- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Prapare Python Package
run: |
python --version
python -m pip install aiofiles aiohttp
- name: Dump Third Party License Info
id: dump-third-party-license-info
continue-on-error: true
run: |
python ./tools/getThirdPartyLicenseJson.py windows ${{ env.THIRD_PARTY_LICENSE_INFO_DIR }}
ls -l ${{ env.THIRD_PARTY_LICENSE_INFO_DIR }}
- name: Dump Third Party License Info (Retry)
if: steps.dump-third-party-license-info.outcome == 'failure'
run: |
python ./tools/getThirdPartyLicenseJson.py windows ${{ env.THIRD_PARTY_LICENSE_INFO_DIR }}
ls -l ${{ env.THIRD_PARTY_LICENSE_INFO_DIR }}
- name: Print Third Party License Info Files
run: cat ${{ env.THIRD_PARTY_LICENSE_INFO_DIR }}/${{ env.THIRD_PARTY_LICENSE_LIST_NAME }}.json

- name: Add AppCenterSecrets.cs
run: |
echo "namespace TRViS;" >> ${{ env.APP_CENTER_SECRETS_FILE_NAME }}
echo "class AppCenterSecrets" >> ${{ env.APP_CENTER_SECRETS_FILE_NAME }}
echo "{" >> ${{ env.APP_CENTER_SECRETS_FILE_NAME }}
echo 'public const string WINDOWS = "${{ secrets.APP_CENTER_SECRET_WINDOWS }}";' >> ${{ env.APP_CENTER_SECRETS_FILE_NAME }}
echo "}" >> ${{ env.APP_CENTER_SECRETS_FILE_NAME }}
ls -l ${{ env.APP_CENTER_SECRETS_FILE_NAME }}
- name: Build x64
run: >
dotnet publish ${{ env.CSPROJ_PATH }}
-f ${{ env.TARGET_FRAMEWORK_WIN }}
-c Release
-o "${{ env.OUTPUT_DIR }}"
/p:WindowsPackageType=None
/p:RuntimeIdentifierOverride=${{ env.TARGET_RUNTIME_WINX64 }}
/p:ApplicationDisplayVersion=${{ needs.get-version.outputs.display_version }}
/p:ApplicationVersion=${{ needs.get-version.outputs.build_number }}
- name: Upload x64
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET_NAME_WIN_X64 }}
path: ${{ env.OUTPUT_DIR }}
retention-days: 3

- name: Clear Output Directory
run: Remove-Item -Recurse -Force -Path ${{ env.OUTPUT_DIR }}

- name: Build x64 Self Contained
run: >
dotnet publish ${{ env.CSPROJ_PATH }}
-f ${{ env.TARGET_FRAMEWORK_WIN }}
-c Release
-o "${{ env.OUTPUT_DIR }}"
/p:WindowsPackageType=None
/p:WindowsAppSDKSelfContained=true
--self-contained
/p:RuntimeIdentifierOverride=${{ env.TARGET_RUNTIME_WINX64 }}
/p:ApplicationDisplayVersion=${{ needs.get-version.outputs.display_version }}
/p:ApplicationVersion=${{ needs.get-version.outputs.build_number }}
- name: Upload x64 Self Contained
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET_NAME_WIN_X64_SELF_CONTAINED }}
path: ${{ env.OUTPUT_DIR }}
retention-days: 3

- name: Clear Output Directory
run: Remove-Item -Recurse -Force -Path ${{ env.OUTPUT_DIR }}

- name: Build x86
run: >
dotnet publish ${{ env.CSPROJ_PATH }}
-f ${{ env.TARGET_FRAMEWORK_WIN }}
-c Release
-o "${{ env.OUTPUT_DIR }}"
/p:WindowsPackageType=None
/p:RuntimeIdentifierOverride=${{ env.TARGET_RUNTIME_WINX86 }}
/p:ApplicationDisplayVersion=${{ needs.get-version.outputs.display_version }}
/p:ApplicationVersion=${{ needs.get-version.outputs.build_number }}
- name: Upload x86
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET_NAME_WIN_X86 }}
path: ${{ env.OUTPUT_DIR }}
retention-days: 3

- name: Clear Output Directory
run: Remove-Item -Recurse -Force -Path ${{ env.OUTPUT_DIR }}

- name: Build x86 Self Contained
run: >
dotnet publish ${{ env.CSPROJ_PATH }}
-f ${{ env.TARGET_FRAMEWORK_WIN }}
-c Release
-o "${{ env.OUTPUT_DIR }}"
/p:WindowsPackageType=None
/p:WindowsAppSDKSelfContained=true
--self-contained
/p:RuntimeIdentifierOverride=${{ env.TARGET_RUNTIME_WINX86 }}
/p:ApplicationDisplayVersion=${{ needs.get-version.outputs.display_version }}
/p:ApplicationVersion=${{ needs.get-version.outputs.build_number }}
- name: Upload x86 Self Contained
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET_NAME_WIN_X86_SELF_CONTAINED }}
path: ${{ env.OUTPUT_DIR }}
retention-days: 3


publish-ios:
if: |
!failure()
Expand Down Expand Up @@ -652,20 +801,60 @@ jobs:
needs:
- set-tag
- build-android
- build-windows

steps:
- name: Download APK
uses: actions/download-artifact@v4
with:
name: apk
path: ${{ env.OUTPUT_DIR }}
- name: Download windows asset (x64)
uses: actions/download-artifact@v4
with:
name: ${{ env.ASSET_NAME_WIN_X64 }}
path: ${{ env.ASSET_NAME_WIN_X64 }}
- name: Download windows asset (x86)
uses: actions/download-artifact@v4
with:
name: ${{ env.ASSET_NAME_WIN_X86 }}
path: ${{ env.ASSET_NAME_WIN_X86 }}
- name: Download windows asset (x64 self-contained)
uses: actions/download-artifact@v4
with:
name: ${{ env.ASSET_NAME_WIN_X64_SELF_CONTAINED }}
path: ${{ env.ASSET_NAME_WIN_X64_SELF_CONTAINED }}
- name: Download windows asset (x86 self-contained)
uses: actions/download-artifact@v4
with:
name: ${{ env.ASSET_NAME_WIN_X86_SELF_CONTAINED }}
path: ${{ env.ASSET_NAME_WIN_X86_SELF_CONTAINED }}

- name: pack win-x64
run: |
7z a -tzip ${{ env.OUTPUT_DIR }}/${{ env.ASSET_NAME_WIN_X64 }}.zip ${{ env.ASSET_NAME_WIN_X64 }}
7z a -t7z ${{ env.OUTPUT_DIR }}/${{ env.ASSET_NAME_WIN_X64 }}.7z ${{ env.ASSET_NAME_WIN_X64 }}
- name: pack win-x86
run: |
7z a -tzip ${{ env.OUTPUT_DIR }}/${{ env.ASSET_NAME_WIN_X86 }}.zip ${{ env.ASSET_NAME_WIN_X86 }}
7z a -t7z ${{ env.OUTPUT_DIR }}/${{ env.ASSET_NAME_WIN_X86 }}.7z ${{ env.ASSET_NAME_WIN_X86 }}
- name: pack win-x64-self-contained
run: |
7z a -tzip ${{ env.OUTPUT_DIR }}/${{ env.ASSET_NAME_WIN_X64_SELF_CONTAINED }}.zip ${{ env.ASSET_NAME_WIN_X64_SELF_CONTAINED }}
7z a -t7z ${{ env.OUTPUT_DIR }}/${{ env.ASSET_NAME_WIN_X64_SELF_CONTAINED }}.7z ${{ env.ASSET_NAME_WIN_X64_SELF_CONTAINED }}
- name: pack win-x86-self-contained
run: |
7z a -tzip ${{ env.OUTPUT_DIR }}/${{ env.ASSET_NAME_WIN_X86_SELF_CONTAINED }}.zip ${{ env.ASSET_NAME_WIN_X86_SELF_CONTAINED }}
7z a -t7z ${{ env.OUTPUT_DIR }}/${{ env.ASSET_NAME_WIN_X86_SELF_CONTAINED }}.7z ${{ env.ASSET_NAME_WIN_X86_SELF_CONTAINED }}
- name: Create Release
run: >
gh release create ${{ needs.set-tag.outputs.tag-name }}
--draft
--generate-notes
${{ env.OUTPUT_DIR }}/*.apk
${{ env.OUTPUT_DIR }}/*.zip
${{ env.OUTPUT_DIR }}/*.7z
--repo ${{ github.repository }}
--notes 'This release is automatically created by actions ... https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}'
env:
Expand Down
3 changes: 3 additions & 0 deletions TRViS/TRViS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows' and '$(RuntimeIdentifierOverride)' != ''">
<RuntimeIdentifier>$(RuntimeIdentifierOverride)</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<WarningLevel>4</WarningLevel>
</PropertyGroup>
Expand Down

0 comments on commit 2b3d6d2

Please sign in to comment.