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.
- 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)
go install github.com/cardinalby/xgo-pack
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
xgo-pack build
It will use xgo-pack-config.yaml
file in the current directory to build and pack your application.
Example tray icon app that is built for all supported platforms is available in the example directory.
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 has common
options on different levels:
targets.common
is used as defaults for all os-es targetstargets.<os>.common
is used as for all architectures of the specified os and is based ontargets.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 binarytargets.macos.<arch>.build_bundle
- build an app bundle for MacOS targetstargets.macos.<arch>.build_dmg
- build a dmg image with app bundle for MacOS targetstargets.linux.<arch>.build_deb
- build deb package for Linux targets
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:
xgo-pack:gui
- for GUI applicationsxgo-pack:tray_icon
- for Tray icon GUI applications
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
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.