Skip to content

chore: workflow publish file #20

chore: workflow publish file

chore: workflow publish file #20

name: CodeGenerator - Windows Release
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
build:
strategy:
matrix:
configuration: [Release]
runs-on: windows-latest
# runs-on: self-hosted
env:
Solution_Name: CodeGenerator.sln
Wpf_Project_Path: CodeGenerator\CodeGenerator.csproj
Output_Dir: ${{ github.workspace }}\publish
Rar_File: ${{ github.workspace }}\CodeGenerator-${{ github.sha }}.rar
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v2
- name: Restore the application
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
env:
Configuration: ${{ matrix.configuration }}
- name: Publish the WPF Application
run: |
dotnet publish $env:Wpf_Project_Path -c $env:Configuration -o $env:Output_Dir
env:
Configuration: ${{ matrix.configuration }}
- name: Compress the published output into .rar
run: |
choco install 7zip -y
# Remove-Item -Force -Path $env:Rar_File
7z a -tzip $env:Rar_File $env:Output_Dir\*
env:
Configuration: ${{ matrix.configuration }}
# - name: Upload the .rar file
# uses: actions/upload-artifact@v4
# with:
# name: CodeGenerator-${{ github.sha }}.rar
# path: $env:Rar_File
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.sha }}
release_name: "Release ${{ github.sha }}"
draft: false
prerelease: false
- name: Upload .rar to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: $env:Rar_File
asset_name: CodeGenerator-${{ github.sha }}.rar
asset_content_type: application/octet-stream