revamp of workflows by Marterich

This commit is contained in:
Chris Titus 2024-08-07 15:24:26 -05:00
parent 5b993adba9
commit 7841f4bbce
8 changed files with 97 additions and 16304 deletions

22
.github/workflows/compile-check.yaml vendored Normal file
View File

@ -0,0 +1,22 @@
name: Compile & Check
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch: # Manual trigger added
workflow_call: # Allow other Actions to call this workflow
jobs:
Compile-and-Check:
runs-on: windows-latest
steps:
- name: Checkout Sources
uses: actions/checkout@v4
- name: Compile and Syntaxcheck winutil.ps1
shell: pwsh
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force; ./Compile.ps1
continue-on-error: false # Directly fail the job on error, removing the need for a separate check

View File

@ -1,48 +0,0 @@
name: Compile
on:
push:
branches:
- main
- test*
workflow_dispatch: # Manual trigger added
jobs:
build-runspace:
runs-on: windows-latest
env:
CERTIFICATE_BASE64: ${{ secrets.CERTIFICATE_BASE64 }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Compile project
shell: pwsh
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force; ./Compile.ps1
continue-on-error: false # Directly fail the job on error, removing the need for a separate check
- name: Create and import code signing certificate
shell: pwsh
run: |
[System.IO.File]::WriteAllBytes("$env:USERPROFILE\code-signing-cert.pfx", [System.Convert]::FromBase64String("$env:CERTIFICATE_BASE64"))
Import-PfxCertificate -FilePath "$env:USERPROFILE\code-signing-cert.pfx" -CertStoreLocation Cert:\CurrentUser\My
- name: Code sign winutil.ps1
shell: pwsh
run: |
$cert = Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert | Select-Object -First 1
if ($null -eq $cert) { throw "Code signing certificate not found" }
Set-AuthenticodeSignature -FilePath ./winutil.ps1 -Certificate $cert
- name: Verify code signature
shell: pwsh
run: |
$signature = Get-AuthenticodeSignature -FilePath ./winutil.ps1
if ($signature.Status -ne 'Valid') { throw "Code signing failed" }
- name: Upload winutil.ps1 as artifact
uses: actions/upload-artifact@v2
with:
name: winutil
path: ./winutil.ps1
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Compile Winutil
if: success()

View File

@ -14,6 +14,12 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Compile project
shell: pwsh
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force; ./Compile.ps1
continue-on-error: false # Directly fail the job on error, removing the need for a separate check
- name: Set Version to Todays Date
id: extract_version
run: |
@ -41,6 +47,31 @@ jobs:
}
shell: pwsh
- name: Create and import code signing certificate
shell: pwsh
run: |
[System.IO.File]::WriteAllBytes("$env:USERPROFILE\code-signing-cert.pfx", [System.Convert]::FromBase64String("$env:CERTIFICATE_BASE64"))
Import-PfxCertificate -FilePath "$env:USERPROFILE\code-signing-cert.pfx" -CertStoreLocation Cert:\CurrentUser\My
- name: Code sign winutil.ps1
shell: pwsh
run: |
$cert = Get-ChildItem -Path Cert:\CurrentUser\My -CodeSigningCert | Select-Object -First 1
if ($null -eq $cert) { throw "Code signing certificate not found" }
Set-AuthenticodeSignature -FilePath ./winutil.ps1 -Certificate $cert
- name: Verify code signature
shell: pwsh
run: |
$signature = Get-AuthenticodeSignature -FilePath ./winutil.ps1
if ($signature.Status -ne 'Valid') { throw "Code signing failed" }
- name: Upload winutil.ps1 as artifact
uses: actions/upload-artifact@v2
with:
name: winutil
path: ./winutil.ps1
- name: Create and Upload Release
id: create_release
uses: softprops/action-gh-release@v2

34
.github/workflows/remove-winutil.yaml vendored Normal file
View File

@ -0,0 +1,34 @@
name: Remove winutil.ps1 if included in a Push
on:
push:
branches:
- '**'
jobs:
check-and-delete-file:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check if winutil.ps1 exists
id: check_existence
run: |
if [ -f "winutil.ps1" ]; then
echo "winutil_exists=true" >> $GITHUB_OUTPUT
else
echo "winutil_exists=false" >> $GITHUB_OUTPUT
fi
- name: Delete winutil.ps1 if it exists
if: steps.check_existence.outputs.winutil_exists == 'true'
run: |
git config --global user.email "winutil-action@noreply.github.com"
git config --global user.name "winutil-action"
git rm winutil.ps1
git commit -m "Delete winutil.ps1 as it is not allowed"
git push origin HEAD:${{ github.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -144,6 +144,16 @@ if ($Debug) {
Set-Content -Path "$workingdir\$scriptname" -Value ($script_content -join "`r`n") -Encoding ascii
Write-Progress -Activity "Compiling" -Completed
Update-Progress -Activity "Validating" -StatusMessage "Checking winutil.ps1 Syntax" -Percent 0
try {
$null = Get-Command -Syntax .\winutil.ps1
}
catch {
Write-Warning "Syntax Validation for 'winutil.ps1' has failed"
Write-Host "$($Error[0])" -ForegroundColor Red
}
Write-Progress -Activity "Validating" -Completed
if ($run) {
try {
Start-Process -FilePath "pwsh" -ArgumentList "$workingdir\$scriptname"

16256
winutil.ps1

File diff suppressed because it is too large Load Diff