From 399733ee2d4c025b40cf88b6555dca2c3f591b4e Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 23 Nov 2021 12:47:42 -0300 Subject: [PATCH] flatpak-builder: Add 'mirror-screenshots-url' input This is required for Flathub. --- README.md | 1 + flatpak-builder/index.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 14e3ca8a..b504953a 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ jobs: | `cache` | Enable/Disable caching `.flatpak-builder` directory | Optional | `true` | | `cache-key` | Specifies the cache key. CPU arch is automatically added, so there is no need to add it to the cache key. | Optional | `flatpak-builder-${sha256(manifestPath)}` | | `arch` | Specifies the CPU architecture to build for | Optional | `x86_64` | +| `mirror-screenshots-url` | Specifies the URL to mirror screenshots | Optional | - | #### Building for multiple CPU architectures diff --git a/flatpak-builder/index.js b/flatpak-builder/index.js index d351eecb..17451a25 100644 --- a/flatpak-builder/index.js +++ b/flatpak-builder/index.js @@ -139,8 +139,9 @@ const getModifiedManifestPath = manifestPath => { * @param {boolean} cacheBuildDir Whether to enable caching the build directory * @param {string} cacheKey The key used to cache the build directory * @param {string} arch The CPU architecture to build for + * @param {string} mirrorScreenshotsUrl The URL to mirror screenshots */ -const build = async (manifest, manifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch) => { +const build = async (manifest, manifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) => { const appId = manifest['app-id'] || manifest.id const branch = manifest.branch || core.getInput('branch') || 'master' @@ -157,6 +158,9 @@ const build = async (manifest, manifestPath, bundle, repositoryUrl, repositoryNa if (cacheBuildDir) { args.push('--ccache') } + if (mirrorScreenshotsUrl) { + args.push(`--mirror-screenshots-url=${mirrorScreenshotsUrl}`) + } args.push(buildDir, manifestPath) await exec.exec('xvfb-run --auto-servernum flatpak-builder', args) @@ -238,6 +242,7 @@ const prepareBuild = async (repositoryName, repositoryUrl, manifestPath, cacheBu * @param {boolean} cacheBuildDir Whether to enable caching the build directory * @param {string} cacheKey the default cache key if there are any * @param {string} arch The CPU architecture to build for + * @param {string} mirrorScreenshotsUrl The URL to mirror screenshots */ const run = async ( manifestPath, @@ -249,7 +254,8 @@ const run = async ( localRepoName, cacheBuildDir, cacheKey, - arch + arch, + mirrorScreenshotsUrl ) => { try { cacheKey = await prepareBuild(repositoryName, repositoryUrl, manifestPath, cacheBuildDir, cacheKey, arch) @@ -264,7 +270,7 @@ const run = async ( return saveManifest(modifiedManifest, modifiedManifestPath) }) .then((manifest) => { - return build(manifest, modifiedManifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch) + return build(manifest, modifiedManifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) }) .then(() => { core.info('Uploading artifact...') @@ -301,6 +307,7 @@ if (require.main === module) { 'repo', ['y', 'yes', 'true', 'enabled', true].includes(core.getInput('cache')), core.getInput('cache-key'), - core.getInput('arch') + core.getInput('arch'), + core.getInput('mirror-screenshots-url') ) }