From 42b8d19527fb009ca4a903d76080aee2d4d01821 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Sun, 29 Oct 2023 13:13:08 +0800 Subject: [PATCH] ci: add ci --- .github/dependabot.yml | 18 ++++ .github/workflows/build.yml | 64 +++++++++++ .github/workflows/check.yml | 15 +++ .github/workflows/ci.yml | 100 ------------------ .github/workflows/release.yml | 39 +++++++ .gitignore | 1 + E-Viewer/E-Viewer-Key.pfx | Bin 0 -> 2614 bytes E-Viewer/E-Viewer.csproj | 24 +++-- .../PublishProfiles/win10-arm64.pubxml | 8 +- .../PublishProfiles/win10-x64.pubxml | 8 +- .../PublishProfiles/win10-x86.pubxml | 20 ---- 11 files changed, 162 insertions(+), 135 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/check.yml delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 E-Viewer/E-Viewer-Key.pfx delete mode 100644 E-Viewer/Properties/PublishProfiles/win10-x86.pubxml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..c00c546a --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + + # Maintain dependencies for nuget + - package-ecosystem: "nuget" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..d417795f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,64 @@ +name: build + +on: + workflow_call: + +jobs: + build: + runs-on: windows-latest + + strategy: + matrix: + arch: [x64, arm64] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1 + + - name: Restore the application + run: msbuild /p:Configuration=Release /p:Platform=${{ matrix.arch }} /t:restore + + # - name: Generate string files + # run: | + # $NugetPackage = nuget locals global-packages -list + # $NugetPackage = $NugetPackage.SubString(17) + # $ToolVersions = (Get-ChildItem (Join-Path $NugetPackage 'Opportunity.ResourceGenerator') | Sort-Object Name -Descending)[0] + # $ToolPath = Join-Path $ToolVersions.FullName '/tools/Opportunity.ResourceGenerator.Generator.exe' + # &$ToolPath "./ExViewer.sln" + + # - name: Generate env files + # run: | + # @" + # namespace ExViewer { class Github { + # public const string BRANCH = "${{ github.ref_name }}"; + # public const string COMMIT = "${{ github.sha }}"; + # } } + # "@ > ./ExViewer/Github.cs + # Get-Content ./ExViewer/Github.cs + + - name: Prepare certificate + run: | + $certKey = "${{ secrets.CERT_PASS }}" + if ($certKey) { + $certFile = Get-Item "./E-Viewer/E-Viewer-Key.pfx" + $certPass = ConvertTo-SecureString -AsPlainText $certKey -Force + Write-Output "Using exist certificate" + Import-PfxCertificate $certFile -Password $certPass -CertStoreLocation Cert:\CurrentUser\My\ + } else { + $cert = New-SelfSignedCertificate -Type CodeSigningCert -Subject "CN=Opportunity" -CertStoreLocation Cert:\CurrentUser\My\ + ((Get-Content -Raw "./E-Viewer/E-Viewer.csproj") -replace 'AC82A857467374ACB64C3F8A542446485164DD50',$cert.Thumbprint) | Set-Content "./E-Viewer/E-Viewer.csproj" + Write-Output "Using new certificate" + Write-Output $cert + } + + - name: Build the application + run: msbuild /p:Configuration=Release /p:Platform=${{ matrix.arch }} /p:GenerateAppxPackageOnBuild=true + + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: Packages + path: E-Viewer/out diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 00000000..465f145a --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,15 @@ +name: check + +on: + push: + branches: ["*"] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + build: + uses: ./.github/workflows/build.yml + secrets: inherit diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 525d836d..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: CI - -on: - push: - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: windows-latest - - strategy: - matrix: - arch: [x64, arm64] - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1 - - - name: Restore the application - run: nuget restore - - - name: Generate string files - run: | - $NugetPackage = nuget locals global-packages -list - $NugetPackage = $NugetPackage.SubString(17) - $ToolVersions = (Get-ChildItem (Join-Path $NugetPackage 'Opportunity.ResourceGenerator') | Sort-Object Name -Descending)[0] - $ToolPath = Join-Path $ToolVersions.FullName '/tools/Opportunity.ResourceGenerator.Generator.exe' - &$ToolPath "./ExViewer.sln" - - - name: Generate env files - run: | - @" - namespace ExViewer { class Github { - public const string BRANCH = "${{ github.ref_name }}"; - public const string COMMIT = "${{ github.sha }}"; - } } - "@ > ./ExViewer/Github.cs - Get-Content ./ExViewer/Github.cs - - - name: Prepare certificate - run: | - $certKey = "${{ secrets.CERT_PASS }}" - if ($certKey) { - $certFile = Get-Item "./ExViewer/ExViewer_TemporaryKey.pfx" - $certPass = ConvertTo-SecureString -AsPlainText $certKey -Force - Write-Output "Using exist certificate" - Import-PfxCertificate $certFile -Password $certPass -CertStoreLocation Cert:\CurrentUser\My\ - } else { - $cert = New-SelfSignedCertificate -Type CodeSigningCert -Subject "CN=Opportunity" -CertStoreLocation Cert:\CurrentUser\My\ - ((Get-Content -Raw "./ExViewer/ExViewer.csproj") -replace 'AC82A857467374ACB64C3F8A542446485164DD50',$cert.Thumbprint) | Set-Content "./ExViewer/ExViewer.csproj" - Write-Output "Using new certificate" - Write-Output $cert - } - - - name: Build the application - run: msbuild ExViewer.sln /p:Configuration=Release /p:Platform=${{ matrix.arch }} - - - name: Upload build artifacts - uses: actions/upload-artifact@v3 - with: - name: Packages - path: ExViewer/AppPackages - - deploy: - needs: build - if: startsWith(github.event.ref, 'refs/tags/') - runs-on: windows-latest - - steps: - - name: Download build artifacts - uses: actions/download-artifact@v3 - with: - name: Packages - path: ./ - - name: Upload symbols - env: - MOBILE_CENTER_CURRENT_APP: Opportunity/E-Viewer - APPCENTER_ACCESS_TOKEN: ${{ secrets.APPCENTER_ACCESS_TOKEN }} - run: | - yarn global add appcenter-cli - $env:Path = "$env:Path;$(yarn global bin)" - Get-ChildItem **/*.appxsym | ForEach-Object { - Write-Output "Uploading $($_.Name)" - appcenter crashes upload-symbols --disable-telemetry --appxsym "$_" - } - - name: Publish to github release - uses: ncipollo/release-action@v1 - with: - draft: true - omitDraftDuringUpdate: true - allowUpdates: true - artifacts: "*/*.msix,*/*.cer,*/*.appxsym" - replacesArtifacts: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..7428edbe --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,39 @@ +name: release + +on: + push: + tags: ["*"] + +jobs: + build: + uses: ./.github/workflows/build.yml + secrets: inherit + + publish: + needs: build + runs-on: windows-latest + + steps: + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: Packages + path: ./ + - name: Upload symbols + env: + MOBILE_CENTER_CURRENT_APP: Opportunity/E-Viewer + APPCENTER_ACCESS_TOKEN: ${{ secrets.APPCENTER_ACCESS_TOKEN }} + run: | + npm install -g appcenter-cli + Get-ChildItem */*.msixsym | ForEach-Object { + Write-Output "Uploading $($_.Name)" + appcenter crashes upload-symbols --disable-telemetry --appxsym "$_" + } + - name: Publish to github release + uses: ncipollo/release-action@v1 + with: + draft: true + omitDraftDuringUpdate: true + allowUpdates: true + artifacts: "*/*.msix,*/*.cer,*/*.msixsym" + replacesArtifacts: true diff --git a/.gitignore b/.gitignore index c262b618..6cf365f6 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ # Build results bin/ obj/ +out/ # Visual Studio cache/options directory .vs/ diff --git a/E-Viewer/E-Viewer-Key.pfx b/E-Viewer/E-Viewer-Key.pfx new file mode 100644 index 0000000000000000000000000000000000000000..64b0bb8c7f80a33a4f4a2c3027b75da17c408e35 GIT binary patch literal 2614 zcmZWpc{tSl7XQr{gR#D0#MrZB7zSg_E+IRkmmnKaIWT`79jB%~mvxV{6 zuASFTQZi{7`@Y|)=ic{y?sK2-^F8NtKIeSS`Tp}gXd+Ar3}QeNSyrGd$QYBDU3L%? zD2K>04#_6&k%VY;bzW5nmwD*(+FsLBOocGI~nvX!Vbvj)wy6>rN|eAyUax-8*NEnJTow{X14+Fk9h1(COQ?t8O(o3ZW8TUE?lBqD3$@|KM#5Hz>G{$z zo!Gl-yJh*60hGj6};!-t4G&9lj zTvHQM5IFqtQ@tl^(tO2fXFMpo?Z6|8-y_%Og9}6V!=Ws0rKX2dDx`FRRVe#5R!>e! z=eex|NL=(=0W8_nIoI&TeX$gZ6Dlrv=e%KJa%0Tnix>EfN+iI7esP!Ldo0Ro;ii3=GFL+F_+mlT%XqMhw zEwW}obJ7kxJ^lbE&G}OVE|3xex-_Ue*BS=p#dwp8mt|UBdpDTpwzJ6ADgY0oPAh%e z22@^j7Wuv;E3R1RUwc}U(Uv!|8xO_&gY&%Uk>}@TGa=C^CXorJvQW&ziZI`1(?0c1 zLXUNlCD>PP$_2BFK7JW{`6DdJ@WzgsYnUCaTsEAl6Rf}C#I>k>DcEN;jK2~rG&k2F zRrvNW(EqDGiV5G9s3pc~?^&FebX%jmS7|b5vx54^553#VHv% zQTFr`TRC9T-xUqqT6E3w2GXK=k;0c#Qx*oAoPx^r_yZ0}D;W5&Zoq7{QJbM_+AfXU zk9cB|Rte`(&Pb9ze~xTEY(Q_;|4low-L7A)IiJc=aW3X9a7O z+L`KTS?!dF%yigyWTqkhu#`I~F_IRwn~U+;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E-Viewer/E-Viewer.csproj b/E-Viewer/E-Viewer.csproj index 762d8ab2..b5442c4e 100644 --- a/E-Viewer/E-Viewer.csproj +++ b/E-Viewer/E-Viewer.csproj @@ -6,15 +6,23 @@ Eviewer app.manifest x64;ARM64 - win10-x86;win10-x64;win10-arm64 + win10-x64;win10-arm64 win10-$(Platform).pubxml true - true + enable en + true + True AC82A857467374ACB64C3F8A542446485164DD50 + out\ True - enable - True + SHA256 + False + True + Never + True + False + 0 @@ -31,7 +39,8 @@ Tools extension to be activated for this project even if the Windows App SDK Nuget package has not yet been restored. --> - + @@ -43,7 +52,8 @@ Explorer "Package and Publish" context menu entry to be enabled for this project even if the Windows App SDK Nuget package has not yet been restored. --> - + true - + \ No newline at end of file diff --git a/E-Viewer/Properties/PublishProfiles/win10-arm64.pubxml b/E-Viewer/Properties/PublishProfiles/win10-arm64.pubxml index a7fdd16b..d5b2134d 100644 --- a/E-Viewer/Properties/PublishProfiles/win10-arm64.pubxml +++ b/E-Viewer/Properties/PublishProfiles/win10-arm64.pubxml @@ -9,10 +9,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121. win10-arm64 bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ true - False - False - True - diff --git a/E-Viewer/Properties/PublishProfiles/win10-x64.pubxml b/E-Viewer/Properties/PublishProfiles/win10-x64.pubxml index 26ea7e55..50a43100 100644 --- a/E-Viewer/Properties/PublishProfiles/win10-x64.pubxml +++ b/E-Viewer/Properties/PublishProfiles/win10-x64.pubxml @@ -9,10 +9,10 @@ https://go.microsoft.com/fwlink/?LinkID=208121. win10-x64 bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ true - False - False - True - diff --git a/E-Viewer/Properties/PublishProfiles/win10-x86.pubxml b/E-Viewer/Properties/PublishProfiles/win10-x86.pubxml deleted file mode 100644 index 34d14d4d..00000000 --- a/E-Viewer/Properties/PublishProfiles/win10-x86.pubxml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - FileSystem - x86 - win10-x86 - bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ - true - False - False - True - - - \ No newline at end of file