Skip to content

Build and pack cross-platform desktop Go application

License

Notifications You must be signed in to change notification settings

cardinalby/xgo-pack

Repository files navigation

Just build and pack your go application

The package is intended to provide an easy way to build and pack your go application for popular platforms.

There are other solutions like goreleaser that are more complex and provide more features.

This package is less flexible and provides fewer features, but is perfect if you need to build and pack your go application for popular platforms with a single command which is a good choice for open-source projects.

Thanks to xgo it's fully os-independent and allows you to cross-build and pack an application for any supported platform and from any platform. The only dependency is docker.

Supported targets

  • MacOS: amd64/arm64
    • binary (+signing)
    • app bundle with icon (+signing)
    • dmg image with app bundle
  • Windows: amd64
    • binary (with embed manifest + icon)
  • Linux: amd64/arm64
    • binary
    • deb package (with desktop entry and icon)

Installation

go install github.com/cardinalby/xgo-pack

Create config file

The first step is creating xgo-pack-config.yaml file in the root of your project. To create a minimal working config file you can use the following command:

xgo-pack init

Start building and packing

xgo-pack build

It will use xgo-pack-config.yaml file in the current directory to build and pack your application.

Check out the example

Example tray icon app that is built for all supported platforms is available in the example directory.

Config details

The config file is a yaml file. To see all available options use any modern IDE that supports json schema available at the repo, also you can refer to Config struct definition in pkg/pipeline/config/cfgtypes/config.go.

Config structure

Config has common options on different levels:

  • targets.common is used as defaults for all os-es targets
  • targets.<os>.common is used as for all architectures of the specified os and is based on targets.common

To enable building a particular artifact (target) you should set targets.<os>.<arch>.build_<artifact> to true:

  • targets.<os>.<arch>.build_bin - build a binary
  • targets.macos.<arch>.build_bundle - build an app bundle for MacOS targets
  • targets.macos.<arch>.build_dmg - build a dmg image with app bundle for MacOS targets
  • targets.linux.<arch>.build_deb - build deb package for Linux targets

Presets

You can use presets as template configs.

presets:
  - my-cfg-template-1.yaml
  - my-cfg-template-2.yaml

Templates are applied in the order they are listed. The last template has the highest priority.

Built-in presets:

Icon

Icon is converted to the target formats using ImageMagick. You can use src icon of any supported format. For psd files add [0] at the end to merge all layers

MacOS signing

rcodesign tool in docker is used for signing MacOS binaries and app bundles. By default, it signs them with self-signed certificate. To set up proper signing, add rcodesign.toml config file to the root of your project.

About

Build and pack cross-platform desktop Go application

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages