Build Flatpak Workflow #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Flatpak Workflow | |
on: | |
workflow_run: | |
workflows: [Build Workflow] | |
types: [completed] | |
inputs: | |
build_type: | |
description: 'Build Configuration to use (Debug, Release, RelWithDebInfo or MinSizeRel).' | |
required: false | |
default: 'Release' | |
jobs: | |
Linux-64: | |
name: Linux x64 | |
runs-on: ubuntu-latest | |
container: | |
image: ubuntu:22.04 | |
options: --privileged | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Set build configuration | |
id: build_configuration | |
run: | | |
BUILD_TYPE=${{github.event.inputs.build_type}} | |
echo "build_type=${BUILD_TYPE:-"Debug"}" >> $GITHUB_OUTPUT | |
- name: Setup Dependencies | |
run: | | |
apt update -y && apt install -y sudo | |
sudo apt-get update -y | |
sudo apt-get install -y ca-certificates gpg wget | |
test -f /usr/share/doc/kitware-archive-keyring/copyright || | |
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null | |
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null | |
sudo apt-get update -y | |
test -f /usr/share/doc/kitware-archive-keyring/copyright || | |
sudo rm /usr/share/keyrings/kitware-archive-keyring.gpg | |
sudo apt-get install kitware-archive-keyring | |
sudo apt install -y file build-essential cmake ninja-build wget gettext p7zip-full libsdl2-dev | |
- name: Download source package | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.payload.workflow_run.id, | |
}); | |
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "Linux-x64" | |
})[0]; | |
let download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
let fs = require('fs'); | |
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/Linux-x64.zip`, Buffer.from(download.data)); | |
- name: Package Flatpak | |
run: | | |
sudo apt install -y flatpak flatpak-builder | |
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo | |
flatpak install --assumeyes --noninteractive flathub org.freedesktop.Platform//23.08 org.freedesktop.Sdk//23.08 | |
7z x Linux-x64.zip -aoa -bd -y | |
tar zxf Linux-x64/max-port-*-Source.tar.gz --directory=Linux-x64 --strip-components=1 | |
cd Linux-x64 | |
sh cmake/scripts/linux/get-dependencies cmake/versions.cmake | |
cd .. | |
flatpak-builder ${{steps.build_configuration.outputs.build_type}} --repo=repo --verbose --force-clean Linux-x64/flatpak/io.github.max-port.yaml | |
flatpak build-bundle --verbose repo max-port.flatpak io.github.max-port | |
mkdir -p ${{steps.build_configuration.outputs.build_type}}/Artifacts/Linux-x64 | |
cp max-port.flatpak ${{steps.build_configuration.outputs.build_type}}/Artifacts/Linux-x64/ | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{github.job}} | |
path: ${{steps.build_configuration.outputs.build_type}}/Artifacts |