Skip to content

Packager

The following workflow is specifically tailored to Packager applications.

Versionining

The release version number can be defined in 3 different file names, the order of priority within which Packager checks them is as follows:

  1. Packager.toml.
  2. packager.json.
  3. Cargo.toml.

In order for any of these files to work, they must be at the root of your project.

Workflow Triggers

For testing and developing purposes it may be useful to set a workflow_dispatch trigger, so the workflow can be initiated from the GitHub UI.

run-name: triggered by ${{ github.actor }}.
on: workflow_dispatch

Once testing is done, it’s recommended to use Continuous Deployment.

on:
push:
branches:
- main

Action Environment

The runtime where Packager will run depends on the app or framework you want to target and the platform you want to build for. We recommend using ubuntu-latest whenever possible, but check the table below for specific use-cases:

FrameworkImage
Tauri v1’ubuntu-20.04’
Tauri v2’ubuntu-22.04’

Once defined, we establish variables so the images can be used consistently across the entire workflow. Additionally we store our CrabNebula Cloud application name to be used in the CLI commands.

env:
CN_APPLICATION: YOUR_ORG_NAME/YOUR_APP_NAME
UBUNTU: "ubuntu-latest"
WINDOWS: "windows-latest"
MACOS: "macos-latest"

Finally, when deploying to multiple platforms, it’s useful to make builds concurrent. Also, cancelling ongoing processes when a new workflow starts.

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

Draft Release

The release draft command will create a new entry in your CrabNebula project, but it won’t upload any assets just yet. It uses the crabnebula-dev/cloud-release action, which requires CN_API_KEY to be defined within your GitHub Action scope.

steps:
- uses: actions/checkout@v4
- name: create draft release
uses: crabnebula-dev/cloud-release@v0
with:
command: release draft ${{ env.CN_APPLICATION }} --framework packager
api-key: ${{ secrets.CN_API_KEY }}

Build Your App

The build step is for setting up the container image in which our task will run for each platform, and finally run Packager to create your binaries.

Establish the dependencies and the matrix of platforms we want to run concurrently. Add Rust toolchain and create a cache for it.

build:
needs: draft
strategy:
fail-fast: false
matrix:
os: [${{ env.UBUNTU }}, ${{ env.MACOS }}, ${{ env.WINDOWS }}]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Install stable toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
- name: install cargo packager
run: |
cargo install cargo-packager --locked
- name: build packager app
run: |
cargo packager --release
- name: Move assets to workdir
run: |
mv target/release/* .

Upload Assets to Cloud

At the last step of our build, we push all assets to the Cloud project. At this point, you will be able to see the binaries showing up in your dashboard. But the release is not published yet!

- name: upload assets
uses: crabnebula-dev/cloud-release@v0
with:
command: release upload ${{ env.CN_APPLICATION }} --framework packager
api-key: ${{ secrets.CN_API_KEY }}

Publishing

At this point, the heavy lifting has been done and it’s time ot publish the release. If you don’t want to autopublish, you can do it manually from the Cloud dashboard.

publish:
needs: build
runs-on: ${{ env.UBUNTU }}
steps:
- uses: actions/checkout@v4
- name: publish release
uses: crabnebula-dev/cloud-release@v0
with:
command: release publish ${{ env.CN_APPLICATION }} --framework packager
api-key: ${{ secrets.CN_API_KEY }}

Full Workflow

name: Packager Release Process
on:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CN_APPLICATION: YOUR_ORG_NAME/YOUR_APP_NAME
UBUNTU: "ubuntu-latest"
WINDOWS: "windows-latest"
MACOS: "macos-latest"
jobs:
draft:
runs-on: ${{ env.UBUNTU }}
steps:
- uses: actions/checkout@v4
- name: create draft release
uses: crabnebula-dev/cloud-release@v0
with:
command: release draft ${{ env.CN_APPLICATION }} --framework packager
api-key: ${{ secrets.CN_API_KEY }}
build:
needs: draft
strategy:
fail-fast: false
matrix:
os: [${{ env.UBUNTU }}, ${{ env.MACOS }}, ${{ env.WINDOWS }}]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Install stable toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
- name: install cargo packager
run: |
cargo install cargo-packager --locked
- name: build packager app
run: |
cargo packager --release
- name: Move assets to workdir
run: |
mv target/release/* .
- name: upload assets
uses: crabnebula-dev/cloud-release@v0
with:
command: release upload ${{ env.CN_APPLICATION }} --framework packager
api-key: ${{ secrets.CN_API_KEY }}
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: publish release
uses: crabnebula-dev/cloud-release@v0
with:
command: release publish ${{ env.CN_APPLICATION }} --framework packager
api-key: ${{ secrets.CN_API_KEY }}