Skip to content

ci: configure snapcraft multi-arch build pipeline - #2

Merged
keyvanarasteh merged 1 commit into
mainfrom
ci/snapcraft-pipeline
Apr 15, 2026
Merged

ci: configure snapcraft multi-arch build pipeline#2
keyvanarasteh merged 1 commit into
mainfrom
ci/snapcraft-pipeline

Conversation

@keyvanarasteh

@keyvanarasteh keyvanarasteh commented Apr 15, 2026

Copy link
Copy Markdown
Owner

Snapcraft mapping.

Summary by Sourcery

Add Snapcraft configuration and CI workflow to build and publish multi-architecture Snap packages for the application.

Build:

  • Introduce Snapcraft manifest defining qleaner snap metadata, strict confinement, and multi-architecture support for amd64 and arm64.

CI:

  • Add GitHub Actions workflow to build amd64/arm64 snaps on tagged releases and publish them to the Snap Store.

@keyvanarasteh
keyvanarasteh merged commit b77e267 into main Apr 15, 2026
@keyvanarasteh
keyvanarasteh deleted the ci/snapcraft-pipeline branch April 15, 2026 18:31
@sourcery-ai

sourcery-ai Bot commented Apr 15, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds Snapcraft packaging configuration and a GitHub Actions workflow to build and publish qleaner as a multi-architecture (amd64/arm64) Snap to the Snap Store on tagged releases.

Sequence diagram for the GitHub Actions Snap build and publish workflow

sequenceDiagram
  actor Developer
  participant GitHub as GitHub_Repository
  participant Workflow as GitHub_Actions_Workflow
  participant Runner as Ubuntu_22_04_Runner
  participant SnapBuild as Snapcore_Action_Build
  participant SnapStore as Snap_Store

  Developer->>GitHub: Push tag v1.0.0
  GitHub-->>Workflow: Trigger workflow snap.yml

  Workflow->>Runner: Start job build with matrix amd64, arm64

  loop For each architecture
    Runner->>Runner: Checkout code actions/checkout
    alt architecture is arm64
      Runner->>Runner: Setup QEMU docker/setup-qemu-action
    end
    Runner->>SnapBuild: Run snapcore/action-build\nwith target-arch
    SnapBuild-->>Runner: Return built snap path

    Runner->>SnapStore: Publish snapcore/action-publish\nusing SNAPCRAFT_STORE_CREDENTIALS
    SnapStore-->>Runner: Confirm release to edge
  end

  Runner-->>Workflow: Job completed for all architectures
Loading

Flow diagram for Snapcraft multi-arch build logic

flowchart TD
  A[Start workflow\ntriggered by tag v* or manual dispatch] --> B[Initialize job build\nwith matrix amd64, arm64]
  B --> C{architecture}
  C -->|amd64| D1[Run on ubuntu-22.04\nno QEMU setup]
  C -->|arm64| D2[Run on ubuntu-22.04\nsetup QEMU via docker/setup-qemu-action]

  D1 --> E[Checkout repository\nactions/checkout@v4]
  D2 --> E

  E --> F[Build Snap\nsnapcore/action-build@v1\n--target-arch=architecture]
  F --> G[Obtain built .snap artifact\nfrom snapBuild.outputs.snap]
  G --> H[Publish to Snap Store\nsnapcore/action-publish@v1\nrelease=edge]
  H --> I[End job for architecture]

  I --> J{More architectures?}
  J -->|yes| C
  J -->|no| K[Workflow complete]
Loading

File-Level Changes

Change Details Files
Introduce Snapcraft manifest to build qleaner as a confined GNOME-based Snap for amd64 and arm64.
  • Define snap metadata including name, base, version, summary, description, grade, and strict confinement.
  • Declare supported architectures for amd64 and arm64 builds.
  • Configure the qleaner app entry with command path, GNOME extension, and basic plugs for network and home access.
  • Add a node-deps part using the npm plugin pinned to Node.js 20.10.0 for frontend dependencies.
  • Add a qleaner-gui part using the rust plugin that builds the Tauri app via npm, then installs the compiled qleaner binary into usr/bin, with necessary build packages for WebKitGTK and related dependencies.
snap/snapcraft.yaml
Create GitHub Actions workflow to build and publish multi-arch Snap artifacts on tags and manual runs.
  • Configure workflow triggers for version tags (v*) and manual workflow_dispatch.
  • Define a matrix job over amd64 and arm64 architectures running on ubuntu-22.04.
  • Set up QEMU emulation conditionally for arm64 builds to support cross-architecture building.
  • Use snapcore/action-build to build the Snap with build-info enabled and pass the target architecture to snapcraft.
  • Use snapcore/action-publish to upload the built Snap to the Snap Store using repository secrets and release it to the edge channel.
.github/workflows/snap.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • The snap version: '1.0.0' in snap/snapcraft.yaml is hard-coded; consider deriving it from the Git tag used to trigger the workflow so the Snap version always matches the released tag.
  • The workflow always publishes to the edge channel regardless of the tag; consider mapping tag patterns (e.g. vX.Y.Z vs pre-releases) to appropriate Snap Store channels to better reflect release stability.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The snap `version: '1.0.0'` in `snap/snapcraft.yaml` is hard-coded; consider deriving it from the Git tag used to trigger the workflow so the Snap version always matches the released tag.
- The workflow always publishes to the `edge` channel regardless of the tag; consider mapping tag patterns (e.g. vX.Y.Z vs pre-releases) to appropriate Snap Store channels to better reflect release stability.

## Individual Comments

### Comment 1
<location path="snap/snapcraft.yaml" line_range="29-36" />
<code_context>
+    source: .
+    npm-node-version: "20.10.0"
+
+  qleaner-gui:
+    after: [node-deps]
+    plugin: rust
+    source: src-tauri
+    override-build: |
+      npm run tauri build
+      mkdir -p $CRAFT_PART_INSTALL/usr/bin
+      cp target/release/qleaner $CRAFT_PART_INSTALL/usr/bin/qleaner
+    build-packages:
+      - libwebkit2gtk-4.1-dev
</code_context>
<issue_to_address>
**suggestion:** Consider whether overriding the Rust plugin build without `craftctl default` is desirable.

Without `craftctl default`, this part won’t use any of the Rust plugin’s standard build/install steps and instead depends entirely on `npm run tauri build` for compilation and artifact placement. If that’s what you want, you may not need the Rust plugin here at all (a `nil` plugin plus explicit commands could be clearer). If you do want the plugin’s defaults (e.g. environment, flags), call `craftctl default` before or after your custom commands.
</issue_to_address>

### Comment 2
<location path=".github/workflows/snap.yml" line_range="16-25" />
<code_context>
+    
+    runs-on: ubuntu-22.04
+    steps:
+      - uses: actions/checkout@v4
+
+      - name: Set up QEMU
+        if: matrix.architecture == 'arm64'
+        uses: docker/setup-qemu-action@v3
+        
+      - name: Build Snap
+        uses: snapcore/action-build@v1
+        id: snapBuild
+        with:
+          build-info: true
+          snapcraft-args: --target-arch=${{ matrix.architecture }}
+
+      - name: Publish to Snap Store
+        uses: snapcore/action-publish@v1
+        env:
</code_context>
<issue_to_address>
**🚨 suggestion (security):** Pin GitHub Actions to specific commit SHAs instead of floating major versions.

These steps are using floating tags (e.g., `@v4`, `@v3`, `@v1`). For stronger supply-chain security and reproducibility, pin each action to a specific commit SHA and, if helpful, add a comment with the corresponding tag to avoid unexpected changes when tags are updated.

Suggested implementation:

```
    steps:
      - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.6

```

```
      - name: Set up QEMU
        if: matrix.architecture == 'arm64'
        uses: docker/setup-qemu-action@49a1486a0f41c5204c7116b7e6e9e0a34c5fefaa # v3

```

```
      - name: Build Snap
        uses: snapcore/action-build@62a453c7fa40a33ecb8b05864f86ce141b0a52f0 # v1

```

```
      - name: Publish to Snap Store
        uses: snapcore/action-publish@1653a9c7c3d6c02ab73e611b795882ec58c2c299 # v1

```

For maximum correctness and security, you should:
1. Confirm each pinned SHA matches the exact released tag you intend to use (e.g., checkout v4.x, setup-qemu-action v3.x, snapcore actions v1.x) by checking the GitHub Marketplace or the action repositories.
2. Update the SHAs in this workflow if you choose different minor/patch versions than assumed here (the pattern of pinning + comment remains the same).
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread snap/snapcraft.yaml
Comment on lines +29 to +36
qleaner-gui:
after: [node-deps]
plugin: rust
source: src-tauri
override-build: |
npm run tauri build
mkdir -p $CRAFT_PART_INSTALL/usr/bin
cp target/release/qleaner $CRAFT_PART_INSTALL/usr/bin/qleaner

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider whether overriding the Rust plugin build without craftctl default is desirable.

Without craftctl default, this part won’t use any of the Rust plugin’s standard build/install steps and instead depends entirely on npm run tauri build for compilation and artifact placement. If that’s what you want, you may not need the Rust plugin here at all (a nil plugin plus explicit commands could be clearer). If you do want the plugin’s defaults (e.g. environment, flags), call craftctl default before or after your custom commands.

Comment on lines +16 to +25
- uses: actions/checkout@v4

- name: Set up QEMU
if: matrix.architecture == 'arm64'
uses: docker/setup-qemu-action@v3

- name: Build Snap
uses: snapcore/action-build@v1
id: snapBuild
with:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Pin GitHub Actions to specific commit SHAs instead of floating major versions.

These steps are using floating tags (e.g., @v4, @v3, @v1). For stronger supply-chain security and reproducibility, pin each action to a specific commit SHA and, if helpful, add a comment with the corresponding tag to avoid unexpected changes when tags are updated.

Suggested implementation:

    steps:
      - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.6

      - name: Set up QEMU
        if: matrix.architecture == 'arm64'
        uses: docker/setup-qemu-action@49a1486a0f41c5204c7116b7e6e9e0a34c5fefaa # v3

      - name: Build Snap
        uses: snapcore/action-build@62a453c7fa40a33ecb8b05864f86ce141b0a52f0 # v1

      - name: Publish to Snap Store
        uses: snapcore/action-publish@1653a9c7c3d6c02ab73e611b795882ec58c2c299 # v1

For maximum correctness and security, you should:

  1. Confirm each pinned SHA matches the exact released tag you intend to use (e.g., checkout v4.x, setup-qemu-action v3.x, snapcore actions v1.x) by checking the GitHub Marketplace or the action repositories.
  2. Update the SHAs in this workflow if you choose different minor/patch versions than assumed here (the pattern of pinning + comment remains the same).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant