Skip to content

Commit

Permalink
Refactor Flatpak build
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdragon-001 committed Jan 21, 2024
1 parent 061fc72 commit 5d068bb
Show file tree
Hide file tree
Showing 13 changed files with 22,462 additions and 160 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,34 @@ jobs:
name: build-axolotl-linux-arm64
path: target/aarch64-unknown-linux-gnu/release/axolotl
retention-days: 1

# See https://github.com/flatpak/flatpak-github-actionsfor examples
flatpak:
name: Flatpak
runs-on: ubuntu-latest
container:
image: bilelmoussaoui/flatpak-github-actions:gnome-45
options: --privileged
strategy:
matrix:
arch: [x86_64, aarch64]
# Don't fail the whole workflow if one architecture fails
fail-fast: false
steps:
- uses: actions/checkout@v4
# Docker is required by the docker/setup-qemu-action which enables emulation
- name: Install deps
if: ${{ matrix.arch != 'x86_64' }}
run: |
dnf -y install docker
- name: Set up QEMU
if: ${{ matrix.arch != 'x86_64' }}
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
manifest-path: flatpak/org.nanuc.Axolotl.yml
branch: ${{ github.head_ref || github.ref_name }}
arch: ${{ matrix.arch }}
19 changes: 0 additions & 19 deletions .github/workflows/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,6 @@ jobs:
path: build/*/app/axolotl.nanuc_*.click
retention-days: 1

# package-flatpak-web:
# name: Package as Flatpak web bundle
# runs-on: ubuntu-latest
# container:
# image: bilelmoussaoui/flatpak-github-actions:freedesktop-22.08
# options: --privileged

# steps:
# - name: Check out code
# uses: actions/checkout@v3

# - name: Build Flatpak Web version
# uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v5
# with:
# bundle: axolotl-web.flatpak
# manifest-path: flatpak/web/org.nanuc.Axolotl.yml
# cache-key: flatpak-builder-web-${{ github.sha }}
# branch: ${{ github.ref_name }}

package-deb-arm64:
name: Package as Debian arm64
runs-on: ubuntu-latest
Expand Down
68 changes: 14 additions & 54 deletions flatpak/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,29 @@ do all need to be fulfilled.

One of these requirements is that of "Stable releases, reproducible builds".

## Dependencies

To be published, all dependencies of the application needs to be listed in the Flatpak manifest.

There is a set of [flatpak builder tools](https://github.com/flatpak/flatpak-builder-tools) provided as to assist with
this dependency listing.

## axolotl-web

The big issue is for the `axolotl-web` dependencies.

Also, for this there is also a tool available,
[flatpak-node-generator](https://github.com/flatpak/flatpak-builder-tools/tree/master/node).
I have however never been able to successfully use it to parse the dependencies, and output it to the required list.

I suspect this is due to the complexity of the relations between the dependencies in node_modules, as I have waited for
several hours without any noticeable change.

Either way, to work around this, the dependencies for a specific version are bundled together and put in this repository.

### Create dependency archive

First, make sure to pull all the git tags.

```
git fetch --all --tags
```

Then check out the published tag. In our case, `v1.0.1`

```
git checkout tags/v1.0.1
```
### axolotl-web

Change to the axolotl-web directory, and make sure to use the npm version specified in the .nvmrc file.
Generate npm/yarn dependencies via [flatpak-node-generator](https://github.com/flatpak/flatpak-builder-tools/tree/master/node):

```
cd axolotl-web/
nvm use
```sh
git clone [email protected]:flatpak/flatpak-builder-tools.git
cd flatpak-builder-tools/node
pipx install .
flatpak-node-generator npm ../../axolotl-web/package-lock.json -o ../../flatpak/node-sources.json
```

Then, from the axolotl-web directory, install all npm dependencies listed in
[package-lock.json](../axolotl-web/package-lock.json).
Note that `python` is required (!) for the node-sass installation to complete.
### axolotl

```
npm ci
```
Generate cargo dependencies via [flatpak-cargo-generator](https://github.com/flatpak/flatpak-builder-tools/tree/master/cargo):

Lastly, create the archive we want, naming it after the tag we checked out before.

```
tar cfvJ ../flatpak/archives/axolotl-web-dependencies-x86_64-v1.0.1.tar.xz node_modules
```sh
sudo apt install python3-aiohttp python3-toml python3-yaml
python3 ./flatpak-cargo-generator.py ../../Cargo.lock -o ../../flatpak/cargo-sources.json
```

To verify, the archive can be extracted by using `tar xvJf axolotl-web-dependencies-x86_64-v1.0.1.tar.xz`.

## Flatpak details

To enter a shell into a built flatpak, use `make debug-flatpak-web`.

### Build directories

* axolotl-electron-bundle: `/run/build/axolotl-electron-bundle`

### Install directories

* axolotl-electron-bundle: `/app/bin/axolotl-electron-bundle`
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 5d068bb

Please sign in to comment.