Skip to content

Commit 820c91a

Browse files
committed
chore: workflow publish file
1 parent 1e31f30 commit 820c91a

File tree

1 file changed

+60
-63
lines changed

1 file changed

+60
-63
lines changed

.github/workflows/dotnet-desktop.yml

+60-63
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,78 @@
1-
# This workflow uses actions that are not certified by GitHub.
2-
# They are provided by a third-party and are governed by
3-
# separate terms of service, privacy policy, and support
4-
# documentation.
5-
6-
# This workflow will build, test, sign and package a WPF or Windows Forms desktop application
7-
# built on .NET Core.
8-
# To learn how to migrate your existing application to .NET Core,
9-
# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework
10-
#
11-
# To configure this workflow:
12-
#
13-
# 1. Configure environment variables
14-
# GitHub sets default environment variables for every workflow run.
15-
# Replace the variables relative to your project in the "env" section below.
16-
#
17-
# 2. Signing
18-
# Generate a signing certificate in the Windows Application
19-
# Packaging Project or add an existing signing certificate to the project.
20-
# Next, use PowerShell to encode the .pfx file using Base64 encoding
21-
# by running the following Powershell script to generate the output string:
22-
#
23-
# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte
24-
# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt'
25-
#
26-
# Open the output file, SigningCertificate_Encoded.txt, and copy the
27-
# string inside. Then, add the string to the repo as a GitHub secret
28-
# and name it "Base64_Encoded_Pfx."
29-
# For more information on how to configure your signing certificate for
30-
# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing
31-
#
32-
# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key".
33-
# See "Build the Windows Application Packaging project" below to see how the secret is used.
34-
#
35-
# For more information on GitHub Actions, refer to https://github.com/features/actions
36-
# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications,
37-
# refer to https://github.com/microsoft/github-actions-for-desktop-apps
38-
39-
name: .NET Core Desktop
1+
name: CodeGenerator - Windows Release
402

413
on:
424
push:
43-
branches: [ "main" ]
5+
branches: ["main"]
446
pull_request:
45-
branches: [ "main" ]
7+
branches: ["main"]
468

479
jobs:
48-
4910
build:
50-
5111
strategy:
5212
matrix:
5313
configuration: [Release]
5414

55-
runs-on: windows-latest # For a list of available runner types, refer to
56-
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
15+
runs-on: windows-latest
5716

5817
env:
59-
Solution_Name: CodeGenerator.sln # Replace with your solution name, i.e. MyWpfApp.sln.
18+
Solution_Name: CodeGenerator.sln
19+
Wpf_Project_Path: CodeGenerator\CodeGenerator.csproj
20+
Output_Dir: ${{ github.workspace }}\publish
6021

6122
steps:
62-
- name: Checkout
63-
uses: actions/checkout@v4
64-
with:
65-
fetch-depth: 0
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Install .NET Core
29+
uses: actions/setup-dotnet@v4
30+
with:
31+
dotnet-version: 8.0.x
32+
33+
- name: Setup MSBuild.exe
34+
uses: microsoft/setup-msbuild@v2
35+
36+
- name: Restore the application
37+
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
38+
env:
39+
Configuration: ${{ matrix.configuration }}
40+
41+
- name: Publish the WPF Application
42+
run: |
43+
dotnet publish $env:Wpf_Project_Path -c $env:Configuration -o $env:Output_Dir
44+
env:
45+
Configuration: ${{ matrix.configuration }}
46+
47+
- name: Compress the published output into .rar
48+
run: |
49+
choco install 7zip -y
50+
7z a $env:Rar_File $env:Output_Dir\*
51+
# Remove-Item -Force -Path $env:Rar_File
52+
# zip -r $env:Rar_File.zip code-generator -x ".git/*" ".github/*"
53+
env:
54+
Configuration: ${{ matrix.configuration }}
6655

67-
# Install the .NET Core workload
68-
- name: Install .NET Core
69-
uses: actions/setup-dotnet@v4
70-
with:
71-
dotnet-version: 8.0.x
56+
- name: Upload the .rar file
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: CodeGenerator-${{ github.sha }}.7z
60+
path: $env:Rar_File
7261

73-
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
74-
- name: Setup MSBuild.exe
75-
uses: microsoft/setup-msbuild@v2
62+
- name: Create GitHub Release
63+
uses: actions/create-release@v1
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
with:
67+
tag_name: ${{ github.sha }}
68+
release_name: "Release ${{ github.sha }}"
69+
draft: false
70+
prerelease: false
7671

77-
# Restore the application to populate the obj folder with RuntimeIdentifiers
78-
- name: Restore the application
79-
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
80-
env:
81-
Configuration: ${{ matrix.configuration }}
72+
- name: Upload .rar to Release
73+
uses: actions/upload-release-asset@v1
74+
with:
75+
upload_url: ${{ steps.create_release.outputs.upload_url }}
76+
asset_path: $env:Rar_File
77+
asset_name: CodeGenerator-${{ github.sha }}.7z
78+
asset_content_type: application/octet-stream

0 commit comments

Comments
 (0)