From 00dcd854db9d3126eaaef495754cb0030f2e073b Mon Sep 17 00:00:00 2001 From: mooms06 Date: Mon, 14 Oct 2024 14:09:53 +0200 Subject: [PATCH] Create rel.yml --- .github/workflows/rel.yml | 118 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 .github/workflows/rel.yml diff --git a/.github/workflows/rel.yml b/.github/workflows/rel.yml new file mode 100644 index 0000000..9f5c4ca --- /dev/null +++ b/.github/workflows/rel.yml @@ -0,0 +1,118 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow will build, test, sign and package a WPF or Windows Forms desktop application +# built on .NET Core. +# To learn how to migrate your existing application to .NET Core, +# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework +# +# To configure this workflow: +# +# 1. Configure environment variables +# GitHub sets default environment variables for every workflow run. +# Replace the variables relative to your project in the "env" section below. +# +# 2. Signing +# Generate a signing certificate in the Windows Application +# Packaging Project or add an existing signing certificate to the project. +# Next, use PowerShell to encode the .pfx file using Base64 encoding +# by running the following Powershell script to generate the output string: +# +# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte +# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt' +# +# Open the output file, SigningCertificate_Encoded.txt, and copy the +# string inside. Then, add the string to the repo as a GitHub secret +# and name it "Base64_Encoded_Pfx." +# For more information on how to configure your signing certificate for +# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing +# +# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key". +# See "Build the Windows Application Packaging project" below to see how the secret is used. +# +# For more information on GitHub Actions, refer to https://github.com/features/actions +# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications, +# refer to https://github.com/microsoft/github-actions-for-desktop-apps + + + name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Version' + required: true + +jobs: + build: + runs-on: windows-latest + + env: + App_Packages_Archive: IdeapadToolkit.zip + License_Path: IdeapadToolkit\Properties\PublishProfiles\3RD_PARTY_LICENSES.txt + App_Publish_Directory: bin\Release\net8.0-windows\publish\win-x64 + App_Project_Directory: IdeapadToolkit\ + Solution_Path: IdeapadToolkit.sln + Project_Path: IdeapadToolkit\IdeapadToolkit.csproj + Actions_Allow_Unsecure_Commands: true # Allows AddPAth and SetEnv commands + Configuration: Release + RuntimeIdentifier: win-x64 + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. + + # Install the .NET Core workload + - name: Install .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' + + # Add MsBuild to the PATH: https://github.com/microsoft/setup-msbuild + - name: Setup MSBuild.exe + uses: microsoft/setup-msbuild@v1.1 + + # Restore the application + - name: Restore the Wpf application to populate the obj folder + run: msbuild $env:Solution_Path /t:Restore /p:Configuration=$env:Configuration /p:RuntimeIdentifier=$env:RuntimeIdentifier + + # Build the Windows Application Packaging project for Prod_Store + - name: Build using the publish profile + run: dotnet publish /p:Configuration=Release /p:PublishProfile=FolderProfile + + # Copy license file to the publish directory + - name: Copy license file to the publish directory + run: Copy-Item -Path $env:License_Path -Destination $env:App_Project_Directory\$env:App_Publish_Directory\ + + # Create archive + - name: Create archive + run: Compress-Archive -Path $env:App_Project_Directory\$env:App_Publish_Directory\* -DestinationPath $env:App_Project_Directory\$env:App_Publish_Directory\$env:App_Packages_Archive + + # Create the release: https://github.com/actions/create-release + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.event.inputs.version }} + release_name: Release ${{ github.event.inputs.version }} + draft: false + prerelease: false + + # Upload release asset: https://github.com/actions/upload-release-asset + - name: Update release asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ${{ env.App_Project_Directory }}\${{ env.App_Publish_Directory }}\${{ env.App_Packages_Archive }} + asset_name: ${{ env.App_Packages_Archive }} + asset_content_type: application/zip