mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 14:45:52 -06:00
revamp of workflows by Marterich
This commit is contained in:
parent
5b993adba9
commit
7841f4bbce
22
.github/workflows/compile-check.yaml
vendored
Normal file
22
.github/workflows/compile-check.yaml
vendored
Normal 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
|
48
.github/workflows/compile.yaml
vendored
48
.github/workflows/compile.yaml
vendored
@ -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()
|
|
31
.github/workflows/pre-release.yaml
vendored
31
.github/workflows/pre-release.yaml
vendored
@ -14,6 +14,12 @@ jobs:
|
|||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
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
|
- name: Set Version to Todays Date
|
||||||
id: extract_version
|
id: extract_version
|
||||||
run: |
|
run: |
|
||||||
@ -41,6 +47,31 @@ jobs:
|
|||||||
}
|
}
|
||||||
shell: pwsh
|
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
|
- name: Create and Upload Release
|
||||||
id: create_release
|
id: create_release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
|
34
.github/workflows/remove-winutil.yaml
vendored
Normal file
34
.github/workflows/remove-winutil.yaml
vendored
Normal 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 }}
|
10
Compile.ps1
10
Compile.ps1
@ -144,6 +144,16 @@ if ($Debug) {
|
|||||||
Set-Content -Path "$workingdir\$scriptname" -Value ($script_content -join "`r`n") -Encoding ascii
|
Set-Content -Path "$workingdir\$scriptname" -Value ($script_content -join "`r`n") -Encoding ascii
|
||||||
Write-Progress -Activity "Compiling" -Completed
|
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) {
|
if ($run) {
|
||||||
try {
|
try {
|
||||||
Start-Process -FilePath "pwsh" -ArgumentList "$workingdir\$scriptname"
|
Start-Process -FilePath "pwsh" -ArgumentList "$workingdir\$scriptname"
|
||||||
|
16256
winutil.ps1
16256
winutil.ps1
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user