Skip to content

Commit

Permalink
ci(nightly): add msix build to nighlys
Browse files Browse the repository at this point in the history
  • Loading branch information
eythaann committed Dec 14, 2024
1 parent e0334bf commit bd8470b
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 41 deletions.
Binary file added .cert/Seelen.cer
Binary file not shown.
Binary file added .cert/Seelen.pfx
Binary file not shown.
1 change: 1 addition & 0 deletions .cert/Seelen.pfx.pwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
seelen
16 changes: 16 additions & 0 deletions .cert/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Self Signed Certificates

In this directory, you will find the self-signed certificates used in the development environment.
You can add it to your system to trust nighly msix packages.

1. Download Seelen.pfx
2. Open a powershell terminal as administrator
4. Go to the directory where you downloaded the file
3. Run the following command
```pwsh
$password = ConvertTo-SecureString -String seelen -Force -AsPlainText
Import-PfxCertificate -FilePath .\Seelen.pfx -CertStoreLocation Cert:\LocalMachine\root -Password $password
```

> [!NOTE]
> These files expire each year and should be replaced with new ones.
25 changes: 25 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,31 @@ jobs:
includeDebug: true
args: ${{ matrix.args }}

- name: Install winget
if: matrix.platform == 'windows-latest'
uses: Cyberboss/install-winget@v1

- name: Install MSIX dependencies
if: matrix.platform == 'windows-latest'
shell: powershell
run: |
winget install --id Microsoft.DotNet.AspNetCore.8 --accept-package-agreements --accept-source-agreements --force
winget install --id Microsoft.DotNet.DesktopRuntime.8 --accept-package-agreements --accept-source-agreements --force
winget install --id MarcinOtorowski.MSIXHero --accept-package-agreements --accept-source-agreements --force
- name: Bundle MSIX
if: matrix.platform == 'windows-latest'
run: npx ts-node scripts/bundle.msix.ts

- name: Upload msix to release
if: matrix.platform == 'windows-latest'
uses: softprops/action-gh-release@v2
with:
tag_name: nightly
name: Seelen UI Nightly
prerelease: true
files: target/release/bundle/*.msix

remove-old-artifacts:
needs: build-installers
permissions:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ node_modules
.env
target
gen
.cert

# Submission Files
/scripts/SBTemp
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "seelen-ui",
"productName": "seelen-ui",
"version": "2.0.12",
"version": "2.0.12+20241019",
"description": "Seelen UI Project",
"scripts": {
"tauri": "tauri",
Expand Down
114 changes: 75 additions & 39 deletions scripts/bundle.msix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,88 @@ import { execSync } from 'child_process';
import fs from 'fs';
import glob from 'glob';
import path from 'path';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';

import packageJson from '../package.json';
import tauriConfig from '../tauri.conf.json';

console.info('Building MSIX...');
const msixCmdsPath = path.resolve('target/release/msix/commands.txt');
const msixTemplatePath = path.resolve('templates/installer.msix');
async function getArgs() {
const argv = await yargs(hideBin(process.argv)).option('target', {
type: 'string',
description: 'target to get the files from',
default: 'release',
}).argv;
return {
target: argv.target,
};
}

const packageVersion = packageJson.version + '.0';
const installer_msix_path = path.resolve(
`target/release/bundle/msix/Seelen.SeelenUI_${packageVersion}_x64__p6yyn03m1894e.msix`,
);
void async function main() {
const { target } = await getArgs();

if (fs.existsSync(msixCmdsPath)) {
fs.rmSync(msixCmdsPath);
} else {
fs.mkdirSync(path.dirname(msixCmdsPath));
}
console.info('Building MSIX...');
const msixCmdsPath = path.resolve(`target/${target}/msix/commands.txt`);
const msixTemplatePath = path.resolve('templates/installer.msix');

fs.appendFileSync(msixCmdsPath, `setIdentity --packageVersion ${packageVersion}\n`);

fs.appendFileSync(
msixCmdsPath,
`addFile --target "${packageJson.productName}.exe" --source "${path.resolve(
`target/release/${packageJson.productName}.exe`,
)}"\n`,
);

tauriConfig.bundle.resources.forEach((pattern) => {
let files = glob.sync(pattern, { nodir: true });
files.forEach((file) => {
fs.appendFileSync(
msixCmdsPath,
`addFile --target "${file}" --source "${path.resolve(`target/release/${file}`)}"\n`,
);
});
});
const [major, minor, patch, nightly_date = 0] = packageJson.version.split(/[\.\+]/);
if (major === undefined || minor === undefined || patch === undefined) {
throw new Error('Invalid package version');
}

// we skip revision here because greater numbers are not supported on msix
const packageVersion = `${major}.${minor}.${patch}.0`;
const postfix = nightly_date ? `+${nightly_date}` : '';
const installer_msix_path = path.resolve(
`target/${target}/bundle/msix/Seelen.SeelenUI_${packageVersion}${postfix}_x64__p6yyn03m1894e.msix`,
);

if (!fs.existsSync(msixCmdsPath)) {
fs.mkdirSync(path.dirname(msixCmdsPath), { recursive: true });
}
fs.writeFileSync(msixCmdsPath, '');

// Set app version
fs.appendFileSync(msixCmdsPath, `setIdentity --packageVersion ${packageVersion}\n`);
// Add main binary
fs.appendFileSync(
msixCmdsPath,
`addFile --target "${packageJson.productName}.exe" --source "${path.resolve(
`target/${target}/${packageJson.productName}.exe`,
)}"\n`,
);

try {
fs.mkdirSync(installer_msix_path.split(path.sep).slice(0, -1).join(path.sep), {
recursive: true,
tauriConfig.bundle.resources.forEach((pattern) => {
let files = glob.sync(pattern, { nodir: true });
files.forEach((file) => {
fs.appendFileSync(
msixCmdsPath,
`addFile --target "${file}" --source "${path.resolve(`target/${target}/${file}`)}"\n`,
);
});
});
fs.copyFileSync(msixTemplatePath, installer_msix_path);

const buffer = execSync(`msixHeroCli edit "${installer_msix_path}" list "${msixCmdsPath}"`);
console.info(buffer.toString());
} catch (error) {
console.error('\n', error);
}
try {
fs.mkdirSync(installer_msix_path.split(path.sep).slice(0, -1).join(path.sep), {
recursive: true,
});
fs.copyFileSync(msixTemplatePath, installer_msix_path);

/* let buffer = execSync(
'msixherocli.exe newcert --directory ./.cert --name Seelen --password seelen --subject CN=7E60225C-94CB-4B2E-B17F-0159A11074CB',
);
console.info(buffer.toString()); */

let buffer = execSync(`msixHeroCli edit "${installer_msix_path}" list "${msixCmdsPath}"`);
console.info(buffer.toString());

buffer = execSync(
`msixHeroCli sign -f ./.cert/Seelen.pfx -p seelen -t http://time.certum.pl ${installer_msix_path}`,
);
console.info(buffer.toString());
} catch (error) {
console.error('\n\n', error);
process.exit(1);
}
}();

0 comments on commit bd8470b

Please sign in to comment.