Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
| `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 | - |
| `upload-artifact` | Enable/Disable uploading the `.flatpak` as a GitHub Actions artifact | Optional | `true` |
| `artifact-name` | The GitHub Actions artifact name | Optional | `${bundle}-${arch}` |

#### Building for multiple CPU architectures

Expand Down
11 changes: 11 additions & 0 deletions flatpak-builder/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ inputs:
description: >
The URL to mirror screenshots.
required: false
upload-artifact:
description: >
Toggles uploading the .flatpak as a GitHub Actions artifact.
Possible values: true, enabled, yes, y. Or something else to disable it.
default: "true"
required: false
artifact-name:
description: >
The name to use when uploading a GitHub Actions artifact.
Defaults to ${bundle}-${arch}
required: false
runs:
using: "node12"
main: "dist/index.js"
29 changes: 20 additions & 9 deletions flatpak-builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ const prepareBuild = async (repositoryName, repositoryUrl, manifestPath, cacheBu
* @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
* @param {boolean} uploadArtifact Whether to upload the .flatpak as an artifact to GitHub Actions
* @param {string} artifactName The artifact name
*/
const run = async (
manifestPath,
Expand All @@ -255,7 +257,9 @@ const run = async (
cacheBuildDir,
cacheKey,
arch,
mirrorScreenshotsUrl
mirrorScreenshotsUrl,
uploadArtifact,
artifactName
) => {
try {
cacheKey = await prepareBuild(repositoryName, repositoryUrl, manifestPath, cacheBuildDir, cacheKey, arch)
Expand All @@ -273,14 +277,19 @@ const run = async (
return build(manifest, modifiedManifestPath, bundle, repositoryUrl, repositoryName, buildDir, localRepoName, cacheBuildDir, cacheKey, arch, mirrorScreenshotsUrl)
})
.then(() => {
core.info('Uploading artifact...')
const artifactClient = artifact.create()
if (uploadArtifact) {
core.info('Uploading artifact...')
const artifactClient = artifact.create()

// Append the arch to the bundle name to prevent conflicts in multi-arch jobs
const bundleName = bundle.replace('.flatpak', '') + `-${arch}`
return artifactClient.uploadArtifact(bundleName, [bundle], '.', {
continueOnError: false
})
// Use the supplied artifactName,
// or append the arch to the bundle name to prevent conflicts in multi-arch jobs
const bundleName = artifactName || bundle.replace('.flatpak', '') + `-${arch}`
return artifactClient.uploadArtifact(bundleName, [bundle], '.', {
continueOnError: false
})
} else {
core.info('Skipping artifact upload')
}
})
.catch((error) => {
core.setFailed(`Build failed: ${error}`)
Expand Down Expand Up @@ -308,6 +317,8 @@ if (require.main === module) {
['y', 'yes', 'true', 'enabled', true].includes(core.getInput('cache')),
core.getInput('cache-key'),
core.getInput('arch'),
core.getInput('mirror-screenshots-url')
core.getInput('mirror-screenshots-url'),
['y', 'yes', 'true', 'enabled', true].includes(core.getInput('upload-artifact')),
core.getInput('artifact-name')
)
}