Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions actions/node/electron-builder/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ inputs:
description: Other arguments to pass to the `electron-builder` command, e.g. configuration overrides
required: false
default: ""
package-manager:
description: "Package manager to use: 'npm' or 'pnpm'"
required: false
default: "npm"

runs:
using: node20
Expand Down
22 changes: 16 additions & 6 deletions actions/node/electron-builder/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27640,12 +27640,15 @@ async function run() {
const electronBuilderArgs = getActionInput('electron-builder-args') || '';
const workingDirectory = getActionInput('working-directory', true);
const githubToken = getActionInput('github-token', true);
const packageManager = getActionInput('package-manager') || 'npm';
const platform = getCurrentOS();
const macosCertificate = getActionInput('macos-certs');
const macosCertificatePassword = getActionInput('macos-certs-password');
const windowsCertificate = getActionInput('windows-certs');
const windowsCertificatePassword = getActionInput('windows-certs-password');

log(`Using package manager: ${packageManager}`);

const packageJsonPath = path.join(workingDirectory, 'package.json');

if (!existsSync(packageJsonPath)) {
Expand All @@ -27667,25 +27670,32 @@ async function run() {
setEnv('NODE_AUTH_TOKEN', githubToken);

// Install dependencies with retry
const installCmd =
packageManager === 'pnpm' ? 'pnpm install --frozen-lockfile --prefer-offline' : 'npm ci';
await withRetry(async () => {
await executeShellCommand('npm ci', workingDirectory);
await executeShellCommand(installCmd, workingDirectory);
}, 'Dependencies installation');

if (!skipBuild) {
// Build script with retry
const buildCmd =
packageManager === 'pnpm'
? `pnpm run ${buildScriptName}`
: `npm run ${buildScriptName} --if-present`;
await withRetry(async () => {
await executeShellCommand(`npm run ${buildScriptName} --if-present`, workingDirectory);
await executeShellCommand(buildCmd, workingDirectory);
}, 'Build script execution');
} else {
log('Skipping build script because `skip-build` option is set');
}

// Electron builder with retry
const ebCmd =
packageManager === 'pnpm'
? `pnpm exec electron-builder --${platform} ${release ? '--publish always' : ''} ${electronBuilderArgs}`
: `npx --no-install electron-builder --${platform} ${release ? '--publish always' : ''} ${electronBuilderArgs}`;
await withRetry(async () => {
await executeShellCommand(
`npx --no-install electron-builder --${platform} ${release ? '--publish always' : ''} ${electronBuilderArgs}`,
workingDirectory,
);
await executeShellCommand(ebCmd, workingDirectory);
}, 'Electron builder execution');

log('Electron application built and signed successfully');
Expand Down
22 changes: 16 additions & 6 deletions actions/node/electron-builder/src/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,15 @@ async function run() {
const electronBuilderArgs = getActionInput('electron-builder-args') || '';
const workingDirectory = getActionInput('working-directory', true);
const githubToken = getActionInput('github-token', true);
const packageManager = getActionInput('package-manager') || 'npm';
const platform = getCurrentOS();
const macosCertificate = getActionInput('macos-certs');
const macosCertificatePassword = getActionInput('macos-certs-password');
const windowsCertificate = getActionInput('windows-certs');
const windowsCertificatePassword = getActionInput('windows-certs-password');

log(`Using package manager: ${packageManager}`);

const packageJsonPath = path.join(workingDirectory, 'package.json');

if (!existsSync(packageJsonPath)) {
Expand All @@ -126,25 +129,32 @@ async function run() {
setEnv('NODE_AUTH_TOKEN', githubToken);

// Install dependencies with retry
const installCmd =
packageManager === 'pnpm' ? 'pnpm install --frozen-lockfile --prefer-offline' : 'npm ci';
await withRetry(async () => {
await executeShellCommand('npm ci', workingDirectory);
await executeShellCommand(installCmd, workingDirectory);
}, 'Dependencies installation');

if (!skipBuild) {
// Build script with retry
const buildCmd =
packageManager === 'pnpm'
? `pnpm run ${buildScriptName}`
: `npm run ${buildScriptName} --if-present`;
await withRetry(async () => {
await executeShellCommand(`npm run ${buildScriptName} --if-present`, workingDirectory);
await executeShellCommand(buildCmd, workingDirectory);
}, 'Build script execution');
} else {
log('Skipping build script because `skip-build` option is set');
}

// Electron builder with retry
const ebCmd =
packageManager === 'pnpm'
? `pnpm exec electron-builder --${platform} ${release ? '--publish always' : ''} ${electronBuilderArgs}`
: `npx --no-install electron-builder --${platform} ${release ? '--publish always' : ''} ${electronBuilderArgs}`;
await withRetry(async () => {
await executeShellCommand(
`npx --no-install electron-builder --${platform} ${release ? '--publish always' : ''} ${electronBuilderArgs}`,
workingDirectory,
);
await executeShellCommand(ebCmd, workingDirectory);
}, 'Electron builder execution');

log('Electron application built and signed successfully');
Expand Down
11 changes: 9 additions & 2 deletions actions/node/prepare-pnpm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ inputs:

pnpm-version:
description: |
Version of pnpm to install
Version of pnpm to install.
Leave empty to use version from packageManager field in package.json.
required: false
default: 'latest'
default: ''

npmrc-config:
description: |
Expand All @@ -53,10 +54,16 @@ runs:
npmrcConfig: ${{ inputs.npmrc-config }}

- name: Install pnpm - ${{ inputs.pnpm-version }}
if: inputs.pnpm-version != ''
uses: pnpm/action-setup@v4
with:
version: ${{ inputs.pnpm-version }}

- name: Install pnpm from packageManager field in package.json
if: inputs.pnpm-version == ''
shell: bash
run: corepack enable pnpm

- name: Set up cache for a NodeJS PNPM application
uses: milaboratory/github-ci/actions/node/cache-pnpm@v4
with:
Expand Down