Skip to content

Commit

Permalink
ci: add initial github action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
joshooaj committed Aug 4, 2024
1 parent f731e77 commit e393c68
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 5 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI
on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- 'v*.*.*'
paths-ignore:
- 'docs/**'
- '*.md'
- 'mkdocs*.yml'
pull_request:
branches:
- 'main'
paths-ignore:
- 'docs/**'
- '*.md'
- 'mkdocs*.yml'

permissions:
id-token: write
contents: read

jobs:
build:
name: Build
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Cache WebView2
id: cache-webview
uses: actions/cache@v4
with:
path: .\cache
key: ${{ runner.os }}-webview

- name: Build
id: build
shell: powershell
run: |
$result = .\build.ps1
$result | Format-Table
"INSTALLERNAME=CascadiaWebContentPlugin.$Version" | Add-Content "$($env:GITHUB_OUTPUT)"
"OUTPUTDIRECTORY=.\output\Setup\en-US\" | Add-Content "$($env:GITHUB_OUTPUT)"
# - name: Azure login
# if: github.ref == 'refs/heads/main'
# uses: Azure/login@v2
# with:
# client-id: ${{ secrets.AZURE_CLIENT_ID }}
# tenant-id: ${{ secrets.AZURE_TENANT_ID }}
# subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# enable-AzPSSession: true

# - name: Sign module
# if: github.ref == 'refs/heads/main'
# shell: powershell
# env:
# AZUREKEYVAULT_URI: ${{ secrets.AZUREKEYVAULT_URI }}
# AZUREKEYVAULT_CERTNAME: ${{ secrets.AZUREKEYVAULT_CERTNAME }}
# run: |
# .\build.ps1 -Task SignWithAzureSignTool

- name: Upload as artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.build.outputs.INSTALLERNAME }}
path: ${{ steps.build.outputs.OUTPUTDIRECTORY }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*.msi
*.zip
output/
.cache/

# User-specific files
*.rsuser
Expand Down
17 changes: 13 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,28 @@ Get-ChildItem $PSScriptRoot\output | Remove-Item -Recurse -Force

# Download WebView2 runtime
$webview2Url = 'https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/c638b5d5-4b2f-4845-baab-c9f4fd6c58ab/MicrosoftEdgeWebView2RuntimeInstallerX64.exe'
if (!(Test-Path $PSScriptRoot\src\Setup\MicrosoftEdgeWebView2RuntimeInstallerX64.exe)) {
$webviewDestination = [io.path]::Combine($PSScriptRoot, '.cache', 'MicrosoftEdgeWebView2RuntimeInstallerX64.exe')
if (!(Test-Path $webviewDestination -PathType Leaf)) {
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri $webview2Url -OutFile $PSScriptRoot\src\Setup\MicrosoftEdgeWebView2RuntimeInstallerX64.exe
Write-Host "Downloading WebView2 Runtime due to cache miss" -ForegroundColor Yellow
Invoke-WebRequest -Uri $webview2Url -OutFile $webviewDestination
}

if (!$PSCmdlet.MyInvocation.BoundParameters.ContainsKey('Version')) {
#$Version = (dotnet nbgv get-version -f json | ConvertFrom-Json).SimpleVersion
$Version = (dotnet nbgv get-version -f json | ConvertFrom-Json).Version
}

Write-Host "Building CascadiaWebContentPlugin.$Version.msi"

& msbuild src/Setup/setup.wixproj /t:Rebuild /restore:True /p:Configuration=Release /p:Platform=x64 /p:BuildVersion=$Version

if (!$?) {
throw "MSBuild exited with code $LASTEXITCODE"
}
Write-Host "Build completed successfully." -ForegroundColor Green

Get-ChildItem $PSScriptRoot\output\Setup\ | Get-FileHash | Select-Object @{n='File';e={([io.fileinfo]$_.Path).Name}}, Hash, Algorithm | ConvertTo-Json | Set-Content $PSScriptRoot\output\Setup\sha256.json
[pscustomobject]@{
Version = $Version
Artifacts = Resolve-Path $PSScriptRoot\output\WebContent
Installer = Resolve-Path $PSScriptRoot\output\Setup\en-US\
}
2 changes: 1 addition & 1 deletion src/Setup/setup.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
Name="pv" Type="raw" Bitness="always32" />
</Property>
<Binary Id="MicrosoftEdgeWebView2RuntimeInstallerX64.exe"
SourceFile="MicrosoftEdgeWebView2RuntimeInstallerX64.exe" />
SourceFile="..\..\.cache\MicrosoftEdgeWebView2RuntimeInstallerX64.exe" />
<CustomAction Id="InvokeStandalone" BinaryRef="MicrosoftEdgeWebView2RuntimeInstallerX64.exe"
Execute="deferred" ExeCommand=" /silent /install" Return="check" />

Expand Down

0 comments on commit e393c68

Please sign in to comment.