Skip to content

Commit

Permalink
revamp of workflows by Marterich
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTitusTech committed Aug 7, 2024
1 parent 5b993ad commit 7841f4b
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 16,304 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/compile-check.yaml
Original file line number Diff line number Diff line change
@@ -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 changes: 0 additions & 48 deletions .github/workflows/compile.yaml

This file was deleted.

File renamed without changes.
31 changes: 31 additions & 0 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/remove-winutil.yaml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
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 }}
File renamed without changes.
10 changes: 10 additions & 0 deletions Compile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading

0 comments on commit 7841f4b

Please sign in to comment.