mirror of
https://github.com/goreleaser/nfpm
synced 2026-11-29 08:54:49 +01:00
Three packagers for macOS, built in pure Go on any platform: - pkg: an installer package (.pkg) from contents and the preinstall and postinstall scripts, as a product archive that declares its architecture. - app: an application bundle delivered as a zip (.app.zip), with a generated Info.plist. - dmg: the same bundle in a disk image (.dmg) next to a link to the Applications folder. app and dmg share the new "app" settings; pkg has its own. All three take name, version, arch and contents from the shared fields, can be signed with a PKCS#12 identity, and report the shared settings macOS has no place for instead of dropping them silently. Refs #535, #536. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
// Package app implements nfpm.Packager providing macOS application bundles,
|
|
// delivered as a zip archive (.app.zip), via the pure-Go
|
|
// go.digitalxero.dev/osx library.
|
|
package app
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
|
|
"github.com/goreleaser/nfpm/v2"
|
|
"github.com/goreleaser/nfpm/v2/internal/macapp"
|
|
)
|
|
|
|
const (
|
|
packagerName = "app"
|
|
extension = ".app.zip"
|
|
)
|
|
|
|
// nolint: gochecknoinits
|
|
func init() {
|
|
nfpm.RegisterPackager(packagerName, Default)
|
|
}
|
|
|
|
// Default app packager.
|
|
// nolint: gochecknoglobals
|
|
var Default = &App{}
|
|
|
|
// App is a macOS application bundle (.app.zip) packager implementation.
|
|
type App struct{}
|
|
|
|
// ConventionalFileName returns the conventional file name for a zipped
|
|
// application bundle: name_version_arch.app.zip.
|
|
func (*App) ConventionalFileName(info *nfpm.Info) string {
|
|
return macapp.FileName(info, extension)
|
|
}
|
|
|
|
// ConventionalExtension returns the file extension for zipped application
|
|
// bundles.
|
|
func (*App) ConventionalExtension() string {
|
|
return extension
|
|
}
|
|
|
|
// Package writes a new zipped macOS application bundle to the given writer
|
|
// using the given info.
|
|
func (*App) Package(info *nfpm.Info, w io.Writer) error {
|
|
built, err := macapp.Build(info, packagerName)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return built.Bundle.Write(context.Background(), w)
|
|
}
|