Files
IPyConsole/.github/workflows/main.yml
2025-02-16 19:10:59 -05:00

104 lines
4.1 KiB
YAML

name: Python Builder
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag Name'
required: true
default: 'v1.0.0'
package_name:
description: 'Package Name'
required: true
default: 'Python'
jobs:
build:
runs-on: windows-2022
env:
SolutionPath: IPyConsole.sln
Platform: Any CPU
Configuration: Debug
BuildMode: SideLoadOnly
AppxBundle: Never
ProjectPath: IPy/IPy.csproj
ProjectDirectory: ./IPy
PackageOutputRootDir: C:\AppPackage
PackageOutputDir: IPy
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Setup NuGet.exe for use with actions
uses: NuGet/setup-nuget@v2.0.0
- name: Generate Self-Signed Certificate
id: generate_cert
run: |
$cert = New-SelfSignedCertificate -CertStoreLocation "Cert:\CurrentUser\My" -Subject "CN=MyUWPCert" -KeyAlgorithm RSA -KeyLength 2048 -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -KeyExportPolicy Exportable -NotAfter (Get-Date).AddYears(1) -Type CodeSigningCert
echo "THUMBPRINT=$($cert.Thumbprint)" >> $env:GITHUB_ENV
shell: pwsh
- name: Set Package Name
id: set_package_name
run: |
echo "PACKAGE_NAME=${{ github.event.inputs.package_name }}_${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- name: App Build
run: |
msbuild $env:SolutionPath `
/p:Platform=$env:Platform `
/p:Configuration=$env:Configuration `
/p:UapAppxPackageBuildMode=$env:BuildMode `
/p:AppxBundle=$env:AppxBundle `
/p:PackageCertificateThumbprint="${{ env.THUMBPRINT }}" `
/p:AppxPackageTestDir="${{ env.PackageOutputRootDir }}\${{ env.PACKAGE_NAME }}" `
/p:AppxPackageSigningEnabled=true `
/restore
shell: pwsh
- name: Clean the Package
run: |
$PackagePath = "${{ env.PackageOutputRootDir }}\${{ env.PACKAGE_NAME }}"
if (Test-Path $PackagePath) {
Write-Host "Cleaning package directory: $PackagePath"
Remove-Item -Recurse -path "$PackagePath\Add-AppDevPackage.resources" -ErrorAction SilentlyContinue
Remove-Item -Recurse -path "$PackagePath\TelemetryDependencies" -ErrorAction SilentlyContinue
Remove-Item -Recurse -path "$PackagePath\Dependencies\arm" -ErrorAction SilentlyContinue
Remove-Item -Recurse -path "$PackagePath\Dependencies\arm64" -ErrorAction SilentlyContinue
Remove-Item -Recurse -path "$PackagePath\Dependencies\x86" -ErrorAction SilentlyContinue
Remove-Item -Recurse -path "$PackagePath\Dependencies\Win32" -ErrorAction SilentlyContinue
Remove-Item -path "$PackagePath\Add-AppDevPackage.ps1" -ErrorAction SilentlyContinue
Remove-Item -Recurse -path "$PackagePath\Install.ps1" -ErrorAction SilentlyContinue
} else {
Write-Host "Package path does not exist: $PackagePath"
exit 1
}
shell: pwsh
- name: Create Archive
run: |
$PackagePath = "${{ env.PackageOutputRootDir }}\${{ env.PACKAGE_NAME }}"
if (Test-Path $PackagePath) {
Write-Host "Creating archive for: $PackagePath"
Compress-Archive -Path "$PackagePath\*" -DestinationPath "${{ env.PackageOutputRootDir }}\${{ env.PACKAGE_NAME }}.zip"
Write-Host "Contents of package output directory after archiving:"
Get-ChildItem -Path "${{ env.PackageOutputRootDir }}" -Recurse
} else {
Write-Host "Package path does not exist for archiving: $PackagePath"
exit 1
}
shell: pwsh
- name: Upload Build Artifact
uses: actions/upload-artifact@v4.3.4
with:
name: ${{ github.event.inputs.package_name }} Build
path: ${{ env.PackageOutputRootDir }}\${{ env.PACKAGE_NAME }}.zip