Skip to content

Commit

Permalink
Add support to "fyne release" for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
lucor committed Nov 28, 2020
1 parent f5af74e commit f7bf51c
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 21 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Supported targets are:

> Note:
> - iOS compilation is supported only on darwin hosts. See [fyne pre-requisites](https://developer.fyne.io/started/#prerequisites) for details.
> - macOS packaging for public distrubution (release mode) is supported only on darwin hosts.
> - windows packaging for public distrubution (release mode) is supported only on windows hosts.
## Requirements
Expand Down
3 changes: 3 additions & 0 deletions docker/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to the fyne-cross docker images will be documented in this f
Release cycle won't follow the fyne-cross one, so the images will be tagged using the label
year.month.day along with the latest one.

# Release 20.11.28
- Update fyne cli to v1.4.2-0.20201127180716-f9f91c194737 fyne-io#1609

# Release 20.11.25
- Update fyne cli to v1.4.2-0.20201125075943-97ad77d2abe0 fyne-io#1538

Expand Down
2 changes: 1 addition & 1 deletion docker/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# docker cross 1.13.15
ARG DOCKER_CROSS_VERSION=sha256:11a04661d910f74c419623ef7880024694f9151c17578af15e86c45cdf6c8588
# fyne stable branch
ARG FYNE_VERSION=97ad77d2abe02267a7da7e32e3685d77d5b084b7
ARG FYNE_VERSION=f9f91c1947370189c73384fb12ee799b1cf68638

# Build the fyne command utility
FROM dockercore/golang-cross@${DOCKER_CROSS_VERSION} AS fyne
Expand Down
17 changes: 14 additions & 3 deletions internal/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,28 @@ func printUsage(template string, data interface{}) {
}

// checkFyneBinHost checks if the fyne cli tool is installed on the host
func checkFyneBinHost() (string, error) {
func checkFyneBinHost(ctx Context) (string, error) {
fyne, err := exec.LookPath("fyne")
if err != nil {
return "", fmt.Errorf("missed requirement: fyne. To install: `go get fyne.io/fyne/cmd/fyne` and add $GOPATH/bin to $PATH")
}

if ctx.Debug {
out, err := exec.Command(fyne, "version").Output()
if err != nil {
return fyne, fmt.Errorf("could not get fyne cli %s version: %v", fyne, err)
}
log.Debugf("%s", out)
}

return fyne, nil
}

// fynePackageHost package the application using the fyne cli tool from the host
// Note: at the moment this is used only for the ios builds
func fynePackageHost(ctx Context) error {

fyne, err := checkFyneBinHost()
fyne, err := checkFyneBinHost(ctx)
if err != nil {
return err
}
Expand Down Expand Up @@ -160,7 +169,7 @@ func fynePackageHost(ctx Context) error {
// Note: at the moment this is used only for the ios and windows builds
func fyneReleaseHost(ctx Context) error {

fyne, err := checkFyneBinHost()
fyne, err := checkFyneBinHost(ctx)
if err != nil {
return err
}
Expand All @@ -182,6 +191,8 @@ func fyneReleaseHost(ctx Context) error {
}

switch ctx.OS {
case darwinOS:
args = append(args, "-category", ctx.Category)
case iosOS:
args = append(args, "-certificate", ctx.Certificate)
args = append(args, "-profile", ctx.Profile)
Expand Down
1 change: 1 addition & 0 deletions internal/command/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type Context struct {
Pull bool // Pull if true attempts to pull a newer version of the docker image

// Release context
Category string //Category represents the category of the app for store listing [macOS]
Certificate string //Certificate represents the name of the certificate to sign the build [iOS, Windows]
Developer string //Developer represents the developer identity for your Microsoft store account [Windows]
Keystore string //Keystore represents the location of .keystore file containing signing information [Android]
Expand Down
54 changes: 37 additions & 17 deletions internal/command/darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ func (cmd *Darwin) Parse(args []string) error {
CommonFlags: commonFlags,
TargetArch: &targetArchFlag{runtime.GOARCH},
}
flagSet.Var(flags.TargetArch, "arch", fmt.Sprintf(`List of target architecture to build separated by comma. Supported arch: %s`, windowsArchSupported))
flagSet.Var(flags.TargetArch, "arch", fmt.Sprintf(`List of target architecture to build separated by comma. Supported arch: %s`, darwinArchSupported))

// flags used only in release mode
flagSet.StringVar(&flags.Category, "category", "", "The name of the certificate to sign the build")

flagAppID := flagSet.Lookup("app-id")
flagAppID.Usage = fmt.Sprintf("%s [required]", flagAppID.Usage)
Expand Down Expand Up @@ -93,10 +96,7 @@ func (cmd *Darwin) Run() error {
return err
}

//
// build
//
err = goBuild(ctx)
err = prepareIcon(ctx)
if err != nil {
return err
}
Expand All @@ -106,20 +106,36 @@ func (cmd *Darwin) Run() error {
//
log.Info("[i] Packaging app...")

packageName := fmt.Sprintf("%s.app", ctx.Output)

err = prepareIcon(ctx)
if err != nil {
return err
}

err = fynePackage(ctx)
if err != nil {
return fmt.Errorf("could not package the Fyne app: %v", err)
var packageName string
var srcFile string
if ctx.Release {
if runtime.GOOS != darwinOS {
return fmt.Errorf("darwin release build is supported only on darwin hosts")
}

packageName = fmt.Sprintf("%s.pkg", ctx.Output)
srcFile = volume.JoinPathHost(ctx.WorkDirHost(), packageName)

err = fyneReleaseHost(ctx)
if err != nil {
return fmt.Errorf("could not package the Fyne app: %v", err)
}
} else {
err = goBuild(ctx)
if err != nil {
return err
}

packageName = fmt.Sprintf("%s.app", ctx.Output)
srcFile = volume.JoinPathHost(ctx.TmpDirHost(), ctx.ID, packageName)

err = fynePackage(ctx)
if err != nil {
return fmt.Errorf("could not package the Fyne app: %v", err)
}
}

// move the dist package into the "dist" folder
srcFile := volume.JoinPathHost(ctx.TmpDirHost(), ctx.ID, packageName)
// move the package into the "dist" folder
distFile := volume.JoinPathHost(ctx.DistDirHost(), ctx.ID, packageName)
err = os.MkdirAll(filepath.Dir(distFile), 0755)
if err != nil {
Expand Down Expand Up @@ -163,6 +179,9 @@ Options:
type darwinFlags struct {
*CommonFlags

//Category represents the category of the app for store listing
Category string

// TargetArch represents a list of target architecture to build on separated by comma
TargetArch *targetArchFlag
}
Expand All @@ -186,6 +205,7 @@ func darwinContext(flags *darwinFlags, args []string) ([]Context, error) {
ctx.Architecture = arch
ctx.OS = darwinOS
ctx.ID = fmt.Sprintf("%s-%s", ctx.OS, ctx.Architecture)
ctx.Category = flags.Category

switch arch {
case ArchAmd64:
Expand Down

0 comments on commit f7bf51c

Please sign in to comment.