From 18d5598cd998349a63b4f49c651ecf65a74ec959 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 23 Dec 2022 15:41:37 +0100 Subject: [PATCH] Add a build-bundle option --- README.md | 1 + flatpak-builder/action.yml | 4 ++++ flatpak-builder/dist/index.js | 34 ++++++++++++++++++++++------------ flatpak-builder/index.js | 34 ++++++++++++++++++++++------------ 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index f3f7e3f5..879e54a4 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ jobs: | --- | ----------- | ----------- |----| | `manifest-path` | The relative path of the manifest file | Required | - | | `bundle` | The bundle name | Optional | `app.flatpak` | +| `build-bundle` | Whether to build a bundle or not | Optional | `true` | | `repository-name` | The repository name, used to fetch the runtime when the user download the Flatpak bundle or when building the application | Optional | `flathub` | | `repository-url` | The repository url, used to fetch the runtime when the user download the Flatpak bundle or when building the application | Optional | `https://flathub.org/repo/flathub.flatpakrepo` | | `run-tests` | Enable/Disable running tests. This overrides the `flatpak-builder` option of the same name, which invokes `make check` or `ninja test`. Network and X11 access is enabled, with a display server provided by `xvfb-run`. | Optional | `false` | diff --git a/flatpak-builder/action.yml b/flatpak-builder/action.yml index 6e0178f2..445790c5 100644 --- a/flatpak-builder/action.yml +++ b/flatpak-builder/action.yml @@ -12,6 +12,10 @@ inputs: description: "The bundle name, by default it's app.flatpak" required: false default: "app.flatpak" + build-bundle: + description: "Whether to build a bundle or not." + default: "true" + required: false repository-url: description: > The repository used to fetch the runtime when the user downloads the diff --git a/flatpak-builder/dist/index.js b/flatpak-builder/dist/index.js index e7497702..7610ff35 100644 --- a/flatpak-builder/dist/index.js +++ b/flatpak-builder/dist/index.js @@ -161,6 +161,7 @@ const getModifiedManifestPath = manifestPath => { * @param {object} manifest A flatpak manifest * @param {object} manifestPath The flatpak manifest path * @param {string} bundle The bundle's name + * @param {boolean} buildBundle Whether to build a bundle or not * @param {string} repositoryUrl The repository used to install the runtime from * @param {string} repositoryName The repository name used to install the runtime from * @param {string} buildDir Where to build the application @@ -170,7 +171,7 @@ const getModifiedManifestPath = manifestPath => { * @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, mirrorScreenshotsUrl) => { +const build = async (manifest, manifestPath, bundle, buildBundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) => { const appId = manifest['app-id'] || manifest.id const branch = manifest.branch || core.getInput('branch') || 'master' @@ -202,16 +203,18 @@ const build = async (manifest, manifestPath, bundle, repositoryUrl, repositoryNa }) } - core.info('Creating a bundle...') - await exec.exec('flatpak', [ - 'build-bundle', - localRepoName, - bundle, - `--runtime-repo=${repositoryUrl}`, - `--arch=${arch}`, - appId, - branch - ]) + if (buildBundle) { + core.info('Creating a bundle...') + await exec.exec('flatpak', [ + 'build-bundle', + localRepoName, + bundle, + `--runtime-repo=${repositoryUrl}`, + `--arch=${arch}`, + appId, + branch + ]) + } } /** @@ -264,6 +267,7 @@ const prepareBuild = async (repositoryName, repositoryUrl, manifestPath, cacheBu * @param {object} manifestPath The flatpak manifest path * @param {boolean} runTests Whether to run tests or not * @param {string} bundle The bundle's name + * @param {boolean} buildBundle Whether to build a bundle or not * @param {string} repositoryUrl The repository used to install the runtime from * @param {string} repositoryName the repository name to install the runtime from * @param {string} buildDir Where to build the application @@ -277,6 +281,7 @@ const run = async ( manifestPath, runTests, bundle, + buildBundle, repositoryUrl, repositoryName, buildDir, @@ -307,7 +312,7 @@ const run = async ( return saveManifest(modifiedManifest, modifiedManifestPath) }) .then((manifest) => { - return build(manifest, modifiedManifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) + return build(manifest, modifiedManifestPath, bundle, buildBundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) }) .then(() => { if (dbusSession) { @@ -315,6 +320,10 @@ const run = async ( dbusSession = null } + if (!buildBundle) { + return + } + core.info('Uploading artifact...') const artifactClient = artifact.create() @@ -348,6 +357,7 @@ if (require.main === require.cache[eval('__filename')]) { core.getInput('manifest-path'), ['y', 'yes', 'true', 'enabled', true].includes(core.getInput('run-tests')), core.getInput('bundle') || 'app.flatpak', + ['y', 'yes', 'true', 'enabled', true].includes(core.getInput('build-bundle')), core.getInput('repository-url'), core.getInput('repository-name'), 'flatpak_app', diff --git a/flatpak-builder/index.js b/flatpak-builder/index.js index 5c1987f6..1bf5bfd0 100644 --- a/flatpak-builder/index.js +++ b/flatpak-builder/index.js @@ -155,6 +155,7 @@ const getModifiedManifestPath = manifestPath => { * @param {object} manifest A flatpak manifest * @param {object} manifestPath The flatpak manifest path * @param {string} bundle The bundle's name + * @param {boolean} buildBundle Whether to build a bundle or not * @param {string} repositoryUrl The repository used to install the runtime from * @param {string} repositoryName The repository name used to install the runtime from * @param {string} buildDir Where to build the application @@ -164,7 +165,7 @@ const getModifiedManifestPath = manifestPath => { * @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, mirrorScreenshotsUrl) => { +const build = async (manifest, manifestPath, bundle, buildBundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) => { const appId = manifest['app-id'] || manifest.id const branch = manifest.branch || core.getInput('branch') || 'master' @@ -196,16 +197,18 @@ const build = async (manifest, manifestPath, bundle, repositoryUrl, repositoryNa }) } - core.info('Creating a bundle...') - await exec.exec('flatpak', [ - 'build-bundle', - localRepoName, - bundle, - `--runtime-repo=${repositoryUrl}`, - `--arch=${arch}`, - appId, - branch - ]) + if (buildBundle) { + core.info('Creating a bundle...') + await exec.exec('flatpak', [ + 'build-bundle', + localRepoName, + bundle, + `--runtime-repo=${repositoryUrl}`, + `--arch=${arch}`, + appId, + branch + ]) + } } /** @@ -258,6 +261,7 @@ const prepareBuild = async (repositoryName, repositoryUrl, manifestPath, cacheBu * @param {object} manifestPath The flatpak manifest path * @param {boolean} runTests Whether to run tests or not * @param {string} bundle The bundle's name + * @param {boolean} buildBundle Whether to build a bundle or not * @param {string} repositoryUrl The repository used to install the runtime from * @param {string} repositoryName the repository name to install the runtime from * @param {string} buildDir Where to build the application @@ -271,6 +275,7 @@ const run = async ( manifestPath, runTests, bundle, + buildBundle, repositoryUrl, repositoryName, buildDir, @@ -301,7 +306,7 @@ const run = async ( return saveManifest(modifiedManifest, modifiedManifestPath) }) .then((manifest) => { - return build(manifest, modifiedManifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) + return build(manifest, modifiedManifestPath, bundle, buildBundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) }) .then(() => { if (dbusSession) { @@ -309,6 +314,10 @@ const run = async ( dbusSession = null } + if (!buildBundle) { + return + } + core.info('Uploading artifact...') const artifactClient = artifact.create() @@ -342,6 +351,7 @@ if (require.main === module) { core.getInput('manifest-path'), ['y', 'yes', 'true', 'enabled', true].includes(core.getInput('run-tests')), core.getInput('bundle') || 'app.flatpak', + ['y', 'yes', 'true', 'enabled', true].includes(core.getInput('build-bundle')), core.getInput('repository-url'), core.getInput('repository-name'), 'flatpak_app',