| 1 |
# Building your App in CI with GitHub Actions |
| 2 |
|
| 3 |
This GitHub [Actions](https://docs.github.com/en/actions) workflow provides the basic framework necessary to test, build, and package a Briefcase project in CI for Windows, Linux, macOS, iOS, and Android. |
| 4 |
|
| 5 |
## Target Platforms |
| 6 |
|
| 7 |
The same set of steps are used for each platform via a [matrix strategy](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow). This will create a separate job for each target platform with specific configuration. |
| 8 |
|
| 9 |
These platforms should be updated to match your targets. To remove a platform, delete the entry from `strategy.matrix.target` as well as the corresponding block of configuration under `strategy.matrix.include`. |
| 10 |
|
| 11 |
To add a new targeted platform, add the name of the target to `strategy.matrix.target`. For instance, to target Linux Flatpak, add an entry to `strategy.matrix.target` named `Flatpak` and a configuration to build a Flatpak under `strategy.matrix.include`, for example: |
| 12 |
|
| 13 |
```YAML |
| 14 |
strategy: |
| 15 |
matrix: |
| 16 |
target: [ "Windows", "macOS", "iOS", "Android", "Flatpak" ] |
| 17 |
include: |
| 18 |
- target: "Flatpak" |
| 19 |
platform: "Linux" |
| 20 |
output-format: "Flatpak" |
| 21 |
runs-on: "ubuntu-latest" |
| 22 |
pre-command: "sudo apt update && sudo apt -y install flatpak flatpak-builder" |
| 23 |
briefcase-run-prefix: "xvfb-run" |
| 24 |
``` |
| 25 |
|
| 26 |
### Target Platform Configuration |
| 27 |
|
| 28 |
These configuration properties can be used to alter behavior of the run for each targeted platform configured in the matrix. |
| 29 |
|
| 30 |
- `target`: Name of the target from `strategy.matrix.target` |
| 31 |
- `platform`: Name of the platform to use in `briefcase` commands; if blank, then `target` is used instead |
| 32 |
- `output-format`: Name of the platform output format for `briefcase` commands |
| 33 |
- `runs-on`: A valid GitHub runner image name for `jobs.<job id>.runs-on` |
| 34 |
- `pre-command`: Arbitrary Bash commands to run before the Briefcase commands |
| 35 |
- `briefcase-args`: Briefcase arguments to use with all `briefcase` commands |
| 36 |
- `briefcase-build-prefix`: Bash commands to prefix to the `briefcase build` command |
| 37 |
- `briefcase-build-args`: Briefcase arguments to use with the `briefcase build` command |
| 38 |
- `briefcase-run-prefix`: Bash commands to prefix to the `briefcase run` command |
| 39 |
- `briefcase-run-args`: Briefcase arguments to use with the `briefcase run` command |
| 40 |
- `briefcase-package-prefix`: Bash commands to prefix to the `briefcase package` command |
| 41 |
- `briefcase-package-args`: Briefcase arguments to use with the `briefcase package` command |
| 42 |
|
| 43 |
## Workflow File Location |
| 44 |
|
| 45 |
This workflow should be saved in to a file at `.github/workflows/ci.yml` in your GitHub repository. Once it exists on your default branch on GitHub, a run will be triggered in the Actions tab. |
| 46 |
|
| 47 |
## Workflow Steps |
| 48 |
|
| 49 |
- Check out the current GitHub repository |
| 50 |
- This will be the version of your repository that triggered the CI run |
| 51 |
- So, for a pull request (PR), this is the code being submitted in the PR |
| 52 |
- After the PR is merged, this is the code in your default branch |
| 53 |
- Install Python 3.12 |
| 54 |
- This version of Python should be updated to match the version of Python your app is targeting |
| 55 |
- Install the latest version of Briefcase |
| 56 |
- Build the test version of the app |
| 57 |
- Run the app's test suite |
| 58 |
- Package the release version of the app for the platform |
| 59 |
- Upload the distributable artefact created for the platform |
| 60 |
- See limitations below for these artefacts |
| 61 |
- If an error occurs, the Briefcase log file is uploaded |
| 62 |
|
| 63 |
## Limitations of Uploaded Artefacts |
| 64 |
|
| 65 |
The artefacts produced and uploaded by this workflow will not be signed; therefore, when the app is executed locally, some platforms may show a disconcerting warning about the security of the app or prevent the app from running altogether. See more information about code signing in the [identity guides][obtain-code-signing-identity]. |
| 66 |
|
| 67 |
## Workflow File Contents |
| 68 |
|
| 69 |
```YAML |
| 70 |
-8<- "how-to/building/workflow.yaml" |
| 71 |
``` |