diff --git a/.github/workflows/linux-openssl1-build-prebuilds.yml b/.github/workflows/linux-openssl1-build-prebuilds.yml new file mode 100644 index 0000000..41a62ef --- /dev/null +++ b/.github/workflows/linux-openssl1-build-prebuilds.yml @@ -0,0 +1,41 @@ +name: Prebuild for Linux x64 With Openssl 1 instead of Openssl 3 + +on: + workflow_dispatch: + +jobs: + build-for-linux: + runs-on: ubuntu-22.04 + env: + NODE_AUTH_TOKEN: ${{ secrets.GH_PACKAGES_TOKEN }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + cache: npm + node-version: 18 + - name: Install toolkit + run: npm ci + - name: Set Electron Major version in env + run: echo "ELECTRON_MAJOR_VERSION=$(node get-electron-major-version.js)" >> $GITHUB_ENV + - name: Download artifact + id: download-artifact + uses: dawidd6/action-download-artifact@v2 + with: + # Optional, GitHub token, a Personal Access Token with `public_repo` scope if needed + # Required, if the artifact is from a different repo + # Required, if the repo is private a Personal Access Token with `repo` scope is needed or GitHub token in a job where the permissions `action` scope set to `read` + github_token: ${{secrets.GITHUB_TOKEN}} + # Optional, workflow file name or ID + # If not specified, will be inferred from run_id (if run_id is specified), or will be the current workflow + workflow: discover-and-prepare-upstream-native-modules.yml + # Optional, the status or conclusion of a completed workflow to search for + # Can be one of a workflow conclusion: + # "failure", "success", "neutral", "cancelled", "skipped", "timed_out", "action_required" + # Or a workflow status: + # "completed", "in_progress", "queued" + # Use the empty string ("") to ignore status or conclusion in the search + workflow_conclusion: success + name: modulesToBuildForElectron-${{ env.ELECTRON_MAJOR_VERSION }} + - name: Build native modules on Linux x64 + run: npm run rebuild-custom-for-target diff --git a/lib/publish.js b/lib/publish.js index 198a15e..15498af 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -29,11 +29,12 @@ export const ghPackageNpmrc = ` @hackolade:registry=https://npm.pkg.github.com always-auth=true`; -export const pkgTpl = ({ githubOrganizationScope, moduleName, targetPlatform, targetArch, version }) => { +export const pkgTpl = ({ githubOrganizationScope, moduleName, targetPlatform, targetArch, version, forOpenSSL1 }) => { const mainFile = (moduleName === 'desktop-trampoline' && 'desktop-trampoline') || 'prebuild.node'; + const opensslSuffix = forOpenSSL1? '-openssl1': ''; return { - name: `${githubOrganizationScope}/${moduleName}-${targetPlatform}-${targetArch}`, + name: `${githubOrganizationScope}/${moduleName}-${targetPlatform}-${targetArch}${opensslSuffix}`, version: `${version}-${electronVersion}`, main: mainFile, files: [mainFile], @@ -51,6 +52,7 @@ export async function writePkgTpl({ moduleName, targetPlatform, targetArch, vers targetArch, version, scopedPackagePath, + forOpenSSL1, }); await writeFile(path.resolve(scopedPackagePath, 'package.json'), JSON.stringify(packageJsonContentForModule)); } @@ -180,6 +182,12 @@ export async function normalizeNativeModulesUnderHackolade(nativeModules) { [`${pkg.name}-darwin-x64`]: prebuildPkgVersion, [`${pkg.name}-darwin-arm64`]: prebuildPkgVersion, }; + + // add openssl1 variant for listed modules that require it + if(name === 'couchbase'){ + depsByTarget[`${pkg.name}-linux-x64-openssl1`] = prebuildPkgVersion; + } + const deps = pkg.dependencies; pkg.dependencies = Object.assign(deps, depsByTarget); diff --git a/rebuild.js b/rebuild.js index a6c77c0..874aabe 100644 --- a/rebuild.js +++ b/rebuild.js @@ -5,7 +5,7 @@ import { prebuildNativeModule } from '#lib/prebuilds.js'; import { npxCommand, exec } from '#lib/commands.js'; import modules from './modulesToBuild.json' assert { type: 'json' }; import { ROOT_DIR } from '#root'; -import { mkdir, cp, readdir, rm } from 'node:fs/promises'; +import { mkdir, cp, readdir,readFile, rm } from 'node:fs/promises'; import path from 'node:path'; import { checkPackageVersionExistsFromPath, publishToGitHubPackages, writePkgTpl } from '#lib/publish.js'; import winAddon from './winapi-detect-remote-desktop-addon/package.json' assert { type: 'json' }; @@ -44,7 +44,13 @@ if (platform() === 'win32') { modulesToBuild.push(remoteDesktopDetectionAddon); } -for (const { module, targetPlatform, targetArch } of modulesToBuild) { +// Detect Ubuntu version to know if we need to specifically build modules for Openssl 1 like Couchbase +const ubuntuReleaseFile = await readFile(path.resolve('/etc/os-release')); + +const mustBuildForOpenSSL1 = ubuntuReleaseFile.toString('UTF8').split('\n').filter(line => line.includes('VERSION_ID=20.04')).length > 0; +const modulesToBuildOnlyForOpenSSL1 = modulesToBuild.filter(module => module.name === 'couchbase'); + +for (const { module, targetPlatform, targetArch } of mustBuildForOpenSSL1 ? modulesToBuildOnlyForOpenSSL1: modulesToBuild) { const prebuildModuleNameForTarget = `${module.name}-${targetPlatform}-${targetArch}`; const nativeModuleScopedPackage = path.join( @@ -62,6 +68,7 @@ for (const { module, targetPlatform, targetArch } of modulesToBuild) { targetArch, scopedPackagePath: nativeModuleScopedPackage, version: module.version, + forOpenSSL1: mustBuildForOpenSSL1, }); const token = env.NODE_AUTH_TOKEN;