Skip to content

Commit

Permalink
switch: prepare App Installer package and manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
yannouuuu committed Aug 4, 2024
1 parent b8c4267 commit 71c69d9
Showing 1 changed file with 36 additions and 64 deletions.
100 changes: 36 additions & 64 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:
exit 1
}
- name: Prepare MSIX package
- name: Prepare App Installer package
run: |
cd zed
Copy-Item ../build-repo/AppxManifest.zed.xml .
Expand Down Expand Up @@ -195,31 +195,32 @@ jobs:
}
}
- name: Prepare MSIX manifest
- name: Prepare App Installer manifest
run: |
cd zed
Copy-Item ../build-repo/AppxManifest.zed.xml .
$manifestContent = Get-Content -Path "AppxManifest.zed.xml" -Raw
$version = $env:LATEST_TAG -replace '^v', '' -replace '-pre$', ''
$version = $version -replace '^(\d+\.\d+\.\d+).*$', '$1' # Keep only X.Y.Z
if ($version -notmatch '^\d+\.\d+\.\d+\.\d+$') {
$version = $version + '.0' # Add a fourth number if necessary
}
$manifestContent = $manifestContent -replace '__VERSION__', $version
$manifestContent | Out-File -FilePath "AppxManifest.xml" -Encoding utf8
Write-Host "Updated version in AppxManifest.xml to: $version"
# Vérifier que l'élément Resources est présent
$xml = [xml](Get-Content "AppxManifest.xml")
if (-not $xml.Package.Resources) {
$resources = $xml.CreateElement("Resources", $xml.Package.NamespaceURI)
$resource = $xml.CreateElement("Resource", $xml.Package.NamespaceURI)
$resource.SetAttribute("Language", "en-us")
$resources.AppendChild($resource)
$xml.Package.AppendChild($resources)
$xml.Save("AppxManifest.xml")
Write-Host "Added Resources element to AppxManifest.xml"
}
$appInstallerContent = @"
<?xml version="1.0" encoding="utf-8"?>
<AppInstaller Uri="https://github.com/${{ github.repository }}/releases/download/${{ env.LATEST_TAG }}/Zed.appinstaller"
Version="$version"
xmlns="http://schemas.microsoft.com/appx/appinstaller/2017/2">
<MainBundle Name="Zed"
Version="$version"
Publisher="CN=ZedIndustries"
Uri="https://github.com/${{ github.repository }}/releases/download/${{ env.LATEST_TAG }}/Zed-windows-amd64-${{ env.LATEST_TAG }}.msixbundle"/>
<UpdateSettings>
<OnLaunch HoursBetweenUpdateChecks="0"/>
</UpdateSettings>
</AppInstaller>
"@
$appInstallerContent | Out-File -FilePath "Zed.appinstaller" -Encoding utf8
Write-Host "Created Zed.appinstaller file"
- name: List directory contents
working-directory: ./zed
Expand All @@ -229,13 +230,6 @@ jobs:
Write-Host "Directory contents:"
Get-ChildItem -Recurse | Select-Object FullName, Length, CreationTime, LastWriteTime
- name: Decode the Pfx
run: |
$pfxBase64 = "${{ secrets.CERTIFICATE_BASE64 }}"
$pfxBytes = [System.Convert]::FromBase64String($pfxBase64)
$certificatePath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath "zed_cert.pfx"
[IO.File]::WriteAllBytes($certificatePath, $pfxBytes)
- name: Copy Zed executable
run: |
$sourceExe = "zed\target\release\deps\zed.exe"
Expand All @@ -248,10 +242,10 @@ jobs:
exit 1
}
- name: Create MSIX package
- name: Create MSIX bundle
working-directory: ./zed
run: |
$outputPackage = "Zed-windows-amd64-$env:LATEST_TAG.msix"
$outputBundle = "Zed-windows-amd64-$env:LATEST_TAG.msixbundle"
$mappingFile = "mapping.txt"
$zedExePath = "target\release\Zed.exe"
Expand Down Expand Up @@ -289,41 +283,13 @@ jobs:
}
}
# Create the MSIX package
& "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\MakeAppx.exe" pack /f $mappingFile /p $outputPackage
# Create the MSIX bundle
& "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\MakeAppx.exe" bundle /f $mappingFile /p $outputBundle
if (Test-Path $outputPackage) {
Write-Host "MSIX package created successfully: $outputPackage"
if (Test-Path $outputBundle) {
Write-Host "MSIX bundle created successfully: $outputBundle"
} else {
Write-Host "Error: Failed to create MSIX package"
exit 1
}
- name: Sign MSIX package
working-directory: ./zed
run: |
$certificatePath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath "zed_cert.pfx"
$msixPath = "Zed-windows-amd64-$env:LATEST_TAG.msix"
Write-Host "Certificate path: $certificatePath"
Write-Host "MSIX path: $msixPath"
if (-not (Test-Path $certificatePath)) {
Write-Host "Error: Certificate file not found"
exit 1
}
if (-not (Test-Path $msixPath)) {
Write-Host "Error: MSIX file not found"
Get-ChildItem -Recurse -Filter *.msix | Select-Object FullName, Length, CreationTime, LastWriteTime
exit 1
}
$signtool = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe"
& $signtool sign /fd SHA256 /a /f $certificatePath /p "${{ secrets.CERTIFICATE_PASSWORD }}" $msixPath
if ($LASTEXITCODE -ne 0) {
Write-Host "SignTool failed with exit code $LASTEXITCODE"
Write-Host "Error: Failed to create MSIX bundle"
exit 1
}
Expand All @@ -333,7 +299,8 @@ jobs:
name: Zed-windows-amd64-${{ env.LATEST_TAG }}
path: |
zed/target/release/Zed-windows-amd64-${{ env.LATEST_TAG }}.exe
zed/Zed-windows-amd64-${{ env.LATEST_TAG }}.msix
zed/Zed-windows-amd64-${{ env.LATEST_TAG }}.msixbundle
zed/Zed.appinstaller
upload-to-release:
needs: [build-windows-amd64]
Expand Down Expand Up @@ -406,8 +373,13 @@ jobs:
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @Zed-windows-amd64-${{ env.LATEST_TAG }}.msix \
"$upload_url?name=Zed-windows-amd64-${{ env.LATEST_TAG }}.msix"
--data-binary @Zed-windows-amd64-${{ env.LATEST_TAG }}.msixbundle \
"$upload_url?name=Zed-windows-amd64-${{ env.LATEST_TAG }}.msixbundle"
curl -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @Zed.appinstaller \
"$upload_url?name=Zed.appinstaller"
- name: Checkout build repository
uses: actions/checkout@v4
Expand Down

0 comments on commit 71c69d9

Please sign in to comment.