Skip to content

Commit 18d5598

Browse files
Add a build-bundle option
1 parent c874574 commit 18d5598

File tree

4 files changed

+49
-24
lines changed

4 files changed

+49
-24
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
| --- | ----------- | ----------- |----|
4343
| `manifest-path` | The relative path of the manifest file | Required | - |
4444
| `bundle` | The bundle name | Optional | `app.flatpak` |
45+
| `build-bundle` | Whether to build a bundle or not | Optional | `true` |
4546
| `repository-name` | The repository name, used to fetch the runtime when the user download the Flatpak bundle or when building the application | Optional | `flathub` |
4647
| `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` |
4748
| `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` |

flatpak-builder/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ inputs:
1212
description: "The bundle name, by default it's app.flatpak"
1313
required: false
1414
default: "app.flatpak"
15+
build-bundle:
16+
description: "Whether to build a bundle or not."
17+
default: "true"
18+
required: false
1519
repository-url:
1620
description: >
1721
The repository used to fetch the runtime when the user downloads the

flatpak-builder/dist/index.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ const getModifiedManifestPath = manifestPath => {
161161
* @param {object} manifest A flatpak manifest
162162
* @param {object} manifestPath The flatpak manifest path
163163
* @param {string} bundle The bundle's name
164+
* @param {boolean} buildBundle Whether to build a bundle or not
164165
* @param {string} repositoryUrl The repository used to install the runtime from
165166
* @param {string} repositoryName The repository name used to install the runtime from
166167
* @param {string} buildDir Where to build the application
@@ -170,7 +171,7 @@ const getModifiedManifestPath = manifestPath => {
170171
* @param {string} arch The CPU architecture to build for
171172
* @param {string} mirrorScreenshotsUrl The URL to mirror screenshots
172173
*/
173-
const build = async (manifest, manifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) => {
174+
const build = async (manifest, manifestPath, bundle, buildBundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) => {
174175
const appId = manifest['app-id'] || manifest.id
175176
const branch = manifest.branch || core.getInput('branch') || 'master'
176177

@@ -202,16 +203,18 @@ const build = async (manifest, manifestPath, bundle, repositoryUrl, repositoryNa
202203
})
203204
}
204205

205-
core.info('Creating a bundle...')
206-
await exec.exec('flatpak', [
207-
'build-bundle',
208-
localRepoName,
209-
bundle,
210-
`--runtime-repo=${repositoryUrl}`,
211-
`--arch=${arch}`,
212-
appId,
213-
branch
214-
])
206+
if (buildBundle) {
207+
core.info('Creating a bundle...')
208+
await exec.exec('flatpak', [
209+
'build-bundle',
210+
localRepoName,
211+
bundle,
212+
`--runtime-repo=${repositoryUrl}`,
213+
`--arch=${arch}`,
214+
appId,
215+
branch
216+
])
217+
}
215218
}
216219

217220
/**
@@ -264,6 +267,7 @@ const prepareBuild = async (repositoryName, repositoryUrl, manifestPath, cacheBu
264267
* @param {object} manifestPath The flatpak manifest path
265268
* @param {boolean} runTests Whether to run tests or not
266269
* @param {string} bundle The bundle's name
270+
* @param {boolean} buildBundle Whether to build a bundle or not
267271
* @param {string} repositoryUrl The repository used to install the runtime from
268272
* @param {string} repositoryName the repository name to install the runtime from
269273
* @param {string} buildDir Where to build the application
@@ -277,6 +281,7 @@ const run = async (
277281
manifestPath,
278282
runTests,
279283
bundle,
284+
buildBundle,
280285
repositoryUrl,
281286
repositoryName,
282287
buildDir,
@@ -307,14 +312,18 @@ const run = async (
307312
return saveManifest(modifiedManifest, modifiedManifestPath)
308313
})
309314
.then((manifest) => {
310-
return build(manifest, modifiedManifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl)
315+
return build(manifest, modifiedManifestPath, bundle, buildBundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl)
311316
})
312317
.then(() => {
313318
if (dbusSession) {
314319
dbusSession.kill()
315320
dbusSession = null
316321
}
317322

323+
if (!buildBundle) {
324+
return
325+
}
326+
318327
core.info('Uploading artifact...')
319328
const artifactClient = artifact.create()
320329

@@ -348,6 +357,7 @@ if (require.main === require.cache[eval('__filename')]) {
348357
core.getInput('manifest-path'),
349358
['y', 'yes', 'true', 'enabled', true].includes(core.getInput('run-tests')),
350359
core.getInput('bundle') || 'app.flatpak',
360+
['y', 'yes', 'true', 'enabled', true].includes(core.getInput('build-bundle')),
351361
core.getInput('repository-url'),
352362
core.getInput('repository-name'),
353363
'flatpak_app',

flatpak-builder/index.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ const getModifiedManifestPath = manifestPath => {
155155
* @param {object} manifest A flatpak manifest
156156
* @param {object} manifestPath The flatpak manifest path
157157
* @param {string} bundle The bundle's name
158+
* @param {boolean} buildBundle Whether to build a bundle or not
158159
* @param {string} repositoryUrl The repository used to install the runtime from
159160
* @param {string} repositoryName The repository name used to install the runtime from
160161
* @param {string} buildDir Where to build the application
@@ -164,7 +165,7 @@ const getModifiedManifestPath = manifestPath => {
164165
* @param {string} arch The CPU architecture to build for
165166
* @param {string} mirrorScreenshotsUrl The URL to mirror screenshots
166167
*/
167-
const build = async (manifest, manifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) => {
168+
const build = async (manifest, manifestPath, bundle, buildBundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl) => {
168169
const appId = manifest['app-id'] || manifest.id
169170
const branch = manifest.branch || core.getInput('branch') || 'master'
170171

@@ -196,16 +197,18 @@ const build = async (manifest, manifestPath, bundle, repositoryUrl, repositoryNa
196197
})
197198
}
198199

199-
core.info('Creating a bundle...')
200-
await exec.exec('flatpak', [
201-
'build-bundle',
202-
localRepoName,
203-
bundle,
204-
`--runtime-repo=${repositoryUrl}`,
205-
`--arch=${arch}`,
206-
appId,
207-
branch
208-
])
200+
if (buildBundle) {
201+
core.info('Creating a bundle...')
202+
await exec.exec('flatpak', [
203+
'build-bundle',
204+
localRepoName,
205+
bundle,
206+
`--runtime-repo=${repositoryUrl}`,
207+
`--arch=${arch}`,
208+
appId,
209+
branch
210+
])
211+
}
209212
}
210213

211214
/**
@@ -258,6 +261,7 @@ const prepareBuild = async (repositoryName, repositoryUrl, manifestPath, cacheBu
258261
* @param {object} manifestPath The flatpak manifest path
259262
* @param {boolean} runTests Whether to run tests or not
260263
* @param {string} bundle The bundle's name
264+
* @param {boolean} buildBundle Whether to build a bundle or not
261265
* @param {string} repositoryUrl The repository used to install the runtime from
262266
* @param {string} repositoryName the repository name to install the runtime from
263267
* @param {string} buildDir Where to build the application
@@ -271,6 +275,7 @@ const run = async (
271275
manifestPath,
272276
runTests,
273277
bundle,
278+
buildBundle,
274279
repositoryUrl,
275280
repositoryName,
276281
buildDir,
@@ -301,14 +306,18 @@ const run = async (
301306
return saveManifest(modifiedManifest, modifiedManifestPath)
302307
})
303308
.then((manifest) => {
304-
return build(manifest, modifiedManifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl)
309+
return build(manifest, modifiedManifestPath, bundle, buildBundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl)
305310
})
306311
.then(() => {
307312
if (dbusSession) {
308313
dbusSession.kill()
309314
dbusSession = null
310315
}
311316

317+
if (!buildBundle) {
318+
return
319+
}
320+
312321
core.info('Uploading artifact...')
313322
const artifactClient = artifact.create()
314323

@@ -342,6 +351,7 @@ if (require.main === module) {
342351
core.getInput('manifest-path'),
343352
['y', 'yes', 'true', 'enabled', true].includes(core.getInput('run-tests')),
344353
core.getInput('bundle') || 'app.flatpak',
354+
['y', 'yes', 'true', 'enabled', true].includes(core.getInput('build-bundle')),
345355
core.getInput('repository-url'),
346356
core.getInput('repository-name'),
347357
'flatpak_app',

0 commit comments

Comments
 (0)