Skip to content

Pre-Release

Pre-Release #111

Workflow file for this run

name: Pre-Release
on:
workflow_dispatch:
inputs:
EnableLoadExtensions:
description: "<EnableLoadExtensions/>"
required: true
default: "Disable"
type: choice
options:
- Enable
- Disable
jobs:
# Reuse the build job from build.yml
Compile:
name: Compile
uses: ./.github/workflows/build.yml
with:
output_dependencies: true
create_package: true
use_preview_version: true
channel: "Preview"
enable_load_extensions: ${{ inputs.EnableLoadExtensions }}
secrets:
PFX_BASE64_ENCODED: ${{ secrets.PFX_BASE64_ENCODED }}
PFX_PASSWORD: ${{ secrets.PFX_PASSWORD }}
Pack:
name: Pack .msixbundle
needs: Compile
runs-on: windows-latest
env:
SigningKey_Path: SigningKey.pfx
Artifacts_Path: .artifacts
steps:
- name: Download .msix from artifacts
uses: actions/download-artifact@v4
with:
pattern: msix-*
merge-multiple: true
path: ${{ env.Artifacts_Path }}
- name: Get Package Information
id: get_package_info
run: |
# Get the name of the .msix file
$file = Get-Item -Path "${{ env.Artifacts_Path }}\*.msix"
if ($file -is [array]) {
$file = $file[0]
}
# Extract the package name with version number
$fileName = [System.IO.Path]::GetFileNameWithoutExtension($file.FullName)
$bundleFileName = $fileName -replace '^(.*?Natsurainko\.FluentLauncher)_(\d+\.\d+\.\d+\.\d+)(_x64|_arm64)$', '$1_$2.msixbundle'
$version = $fileName -replace '^(.*?Natsurainko\.FluentLauncher)_(\d+\.\d+\.\d+\.\d+)(_x64|_arm64)$', '$2'
echo "::set-output name=bundleFileName::$bundleFileName"
echo "::set-output name=version::$version"
- name: Create .msixbundle
run: |
# Get makeappx.exe
$makeappx = Get-Item -Path "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\makeappx.exe"
if ($makeappx -is [array]) {
$makeappx = $makeappx[0]
}
# Create the .msixbundle using makeappx.exe
& $makeappx.FullName bundle /d "${{ env.Artifacts_Path }}" /p "${{ steps.get_package_info.outputs.bundleFileName }}" /bv "${{ steps.get_package_info.outputs.version }}"
# Decode the base 64 encoded pfx and sign the package
- name: Sign .msixbundle
run: |
# Get signtool.exe
$signtool = Get-Item -Path "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\signtool.exe"
if ($signtool -is [array]) {
$signtool = $signtool[0]
}
# Sign .msixbundle
$pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.PFX_BASE64_ENCODED }}")
[IO.File]::WriteAllBytes("${{ env.SigningKey_Path }}", $pfx_cert_byte)
& $signtool sign /f "${{ env.SigningKey_Path }}" /p "${{ secrets.PFX_PASSWORD }}" /fd SHA256 /td SHA256 "${{ steps.get_package_info.outputs.bundleFileName }}"
rm "${{ env.SigningKey_Path }}"
- name: Upload .msixbundle to artifacts
uses: actions/upload-artifact@v4
with:
name: .msixbundle
path: ${{ steps.get_package_info.outputs.bundleFileName }}
Release:
runs-on: windows-latest
name: Release
needs: [Compile, Pack]
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Config User
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub-actions[bot]"
- name: Download x64 msixbundle
uses: actions/download-artifact@v4
with:
name: msix-x64
path: "${{ github.workspace }}\\updatePackage-x64"
- name: Download x64 dependencies
uses: actions/download-artifact@v4
with:
name: dependencies-x64
path: "${{ github.workspace }}\\updatePackage-x64\\dependencies"
- name: Create x64 update package
run: |
cd "${{ github.workspace }}\\updatePackage-x64\\dependencies"
tar -xf dependencies-x64.zip -C ./
Remove-Item dependencies-x64.zip
cd "${{ github.workspace }}\\updatePackage-x64"
Rename-Item *.msix msix-x64.msix
Compress-Archive -Path .\\* -DestinationPath ..\\updatePackage-x64.zip
- name: Download arm64 msixbundle
uses: actions/download-artifact@v4
with:
name: msix-arm64
path: "${{ github.workspace }}\\updatePackage-arm64"
- name: Download arm64 dependencies
uses: actions/download-artifact@v4
with:
name: dependencies-arm64
path: "${{ github.workspace }}\\updatePackage-arm64\\dependencies"
- name: Create arm64 update package
run: |
cd "${{ github.workspace }}\\updatePackage-arm64\\dependencies"
tar -xf dependencies-arm64.zip -C ./
Remove-Item dependencies-arm64.zip
cd "${{ github.workspace }}\\updatePackage-arm64"
Rename-Item *.msix msix-arm64.msix
Compress-Archive -Path .\\* -DestinationPath ..\\updatePackage-arm64.zip
- name: Download msixbundle
uses: actions/download-artifact@v4
with:
name: .msixbundle
path: "${{ github.workspace }}\\${{env.Artifacts_Path}}"
- name: Rename msixbundle
run: |
cd "${{ github.workspace }}"
Rename-Item *.msixbundle package.msixbundle
- name: Download Artifacts (dependencies)
uses: actions/download-artifact@v4
with:
pattern: dependencies-*
path: "${{ github.workspace }}\\${{env.Artifacts_Path}}"
- name: Create Release Information
run: |
.\update-appxmanifest.ps1
$stableManifestPath = Resolve-Path -Path "Natsurainko.FluentLauncher\Package-Stable.appxmanifest"
[xml]$stableXmlContent = Get-Content -Path $stableManifestPath
$previewManifestPath = Resolve-Path -Path "Natsurainko.FluentLauncher\Package-Preview.appxmanifest"
[xml]$previewXmlContent = Get-Content -Path $previewManifestPath
$packageFiles = @("${{ github.workspace }}\updatePackage-x64.zip", "${{ github.workspace }}\updatePackage-arm64.zip")
$commit = $env:GITHUB_SHA.Substring(0, 7)
$build = [int]$previewXmlContent.Package.Identity.Version.Split('.')[-1]
$previousStableVersion = [string]$stableXmlContent.Package.Identity.Version
$currentPreviewVersion = [string]$previewXmlContent.Package.Identity.Version
$jsonNode = [System.Text.Json.Nodes.JsonObject]::new()
$jsonNode["commit"] = $commit
$jsonNode["build"] = $build
$jsonNode["releaseTime"] = (Get-Date -Format "yyyy-MM-ddTHH:mm:ss")
$jsonNode["currentPreviewVersion"] = $currentPreviewVersion
$jsonNode["previousStableVersion"] = $previousStableVersion
if ("${{ inputs.EnableLoadExtensions }}" -eq "Enable") {
$jsonNode["enableLoadExtensions"] = $true
}
$hashesNode = [System.Text.Json.Nodes.JsonObject]::new()
foreach ($packageFile in $packageFiles) {
$md5 = [System.Security.Cryptography.MD5]::Create()
$stream = [System.IO.File]::OpenRead($packageFile)
$hashBytes = $md5.ComputeHash($stream)
$stream.Close()
$hash = [System.BitConverter]::ToString($hashBytes) -replace '-', ''
$hashesNode[([System.IO.Path]::GetFileName($packageFile))] = $hash.ToLower()
}
$jsonNode["hashes"] = $hashesNode
$SerializerOptions = [System.Text.Json.JsonSerializerOptions]::new()
$SerializerOptions.WriteIndented = $true
$result = $jsonNode.ToJsonString($SerializerOptions)
$markdown = "`````` json`n$result`n``````"
Set-Content -Path "${{ github.workspace }}\body.md" -Value $markdown
echo "currentPreviewVersion=$currentPreviewVersion" >> $env:GITHUB_ENV
echo "commit=$commit" >> $env:GITHUB_ENV
- name: Create Release
uses: ncipollo/[email protected]
with:
artifacts: "${{ github.workspace }}\\updatePackage-*.zip,${{ github.workspace }}\\package.msixbundle"
allowUpdates: true
generateReleaseNotes: true
prerelease: true
tag: "pre-release-v${{ env.currentPreviewVersion }}"
bodyFile: "${{ github.workspace }}\\body.md"
- name: Upload Files To Oss
uses: xcube-studio/sync2oss@v2
with:
repoUrl: "Xcube-Studio/Natsurainko.FluentLauncher"
accessKeyId: ${{ secrets.ALIYUN_ACCESSKEYID }}
accessKeySecret: ${{secrets.ALIYUN_ACCESSKEYSECRET}}
endpoint: ${{secrets.ALIYUN_OSS_ENDPOINT}}
bucketName: ${{secrets.ALIYUN_OSS_BUCKETNAME_1}}
region: "cn-shanghai"
addSymlink: True
isPre: True
fromRelease: True
remoteDir: "Natsurainko.FluentLauncher"