Skip to content

Commit

Permalink
flatpak-builder: Add 'mirror-screenshots-url' input
Browse files Browse the repository at this point in the history
This is required for Flathub.
  • Loading branch information
GeorgesStavracas authored and bilelmoussaoui committed Nov 23, 2021
1 parent 1540a90 commit 9b33ba8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 11 additions & 4 deletions flatpak-builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -249,7 +254,8 @@ const run = async (
localRepoName,
cacheBuildDir,
cacheKey,
arch
arch,
mirrorScreenshotsUrl
) => {
try {
cacheKey = await prepareBuild(repositoryName, repositoryUrl, manifestPath, cacheBuildDir, cacheKey, arch)
Expand All @@ -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...')
Expand Down Expand Up @@ -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')
)
}

0 comments on commit 9b33ba8

Please sign in to comment.