Skip to content

Commit

Permalink
Merge branch 'develop' into features/propagate-goflags-env
Browse files Browse the repository at this point in the history
  • Loading branch information
Cedric BAIL committed Jan 6, 2024
2 parents 80fe656 + 049e534 commit 5b88091
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"

6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# use max/min supported Go versions
go-version: ["1.18.x", "1.14.x"]
go-version: ["1.21.x", "1.17.x"]

steps:
- name: Setup Go environment
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
fail-fast: false
matrix:
# use max/min supported Go versions
go-version: ["1.18.x", "1.14.x"]
go-version: ["1.21.x", "1.17.x"]
target:
- os: linux
- os: windows
Expand Down Expand Up @@ -162,7 +162,7 @@ jobs:
fail-fast: false
matrix:
# use max/min supported Go versions
go-version: ["1.18.x", "1.14.x"]
go-version: ["1.21.x", "1.17.x"]
target:
- os: linux
- os: windows
Expand Down
3 changes: 3 additions & 0 deletions internal/command/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (cmd *android) Parse(args []string) error {
flagSet.StringVar(&flags.Keystore, "keystore", "", "The location of .keystore file containing signing information")
flagSet.StringVar(&flags.KeystorePass, "keystore-pass", "", "Password for the .keystore file")
flagSet.StringVar(&flags.KeyPass, "key-pass", "", "Password for the signer's private key, which is needed if the private key is password-protected")
flagSet.StringVar(&flags.KeyName, "key-name", "", "Name of the key to use for signing")

flagSet.Usage = cmd.Usage
flagSet.Parse(args)
Expand Down Expand Up @@ -147,6 +148,7 @@ type androidFlags struct {
Keystore string //Keystore represents the location of .keystore file containing signing information
KeystorePass string //Password for the .keystore file
KeyPass string //Password for the signer's private key, which is needed if the private key is password-protected
KeyName string //Name of the key to use for signing

// TargetArch represents a list of target architecture to build on separated by comma
TargetArch *targetArchFlag
Expand Down Expand Up @@ -196,6 +198,7 @@ func (cmd *android) setupContainerImages(flags *androidFlags, args []string) err
cmd.defaultContext.Keystore = volume.JoinPathContainer(cmd.defaultContext.Volume.WorkDirContainer(), flags.Keystore)
cmd.defaultContext.KeystorePass = flags.KeystorePass
cmd.defaultContext.KeyPass = flags.KeyPass
cmd.defaultContext.KeyName = flags.KeyName

cmd.Images = append(cmd.Images, image)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func fyneCommand(binary, command, icon string, ctx Context, image containerImage
// add tags to command, if any
tags := image.Tags()
if len(tags) > 0 {
args = append(args, "-tags", fmt.Sprintf("%q", strings.Join(tags, ",")))
args = append(args, "-tags", strings.Join(tags, ","))
}

if ctx.Metadata != nil {
Expand Down
3 changes: 3 additions & 0 deletions internal/command/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ func fyneRelease(ctx Context, image containerImage) error {
if ctx.KeyPass != "" {
args = append(args, "-keyPass", ctx.KeyPass)
}
if ctx.KeyName != "" {
args = append(args, "-keyName", ctx.KeyName)
}
case iosOS:
if ctx.Certificate != "" {
args = append(args, "-certificate", ctx.Certificate)
Expand Down
1 change: 1 addition & 0 deletions internal/command/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ type Context struct {
Keystore string //Keystore represents the location of .keystore file containing signing information [Android]
KeystorePass string //KeystorePass represents the password for the .keystore file [Android]
KeyPass string //KeyPass represents the assword for the signer's private key, which is needed if the private key is password-protected [Android]
KeyName string //KeyName represents the name of the key to sign the build [Android]
Password string //Password represents the password for the certificate used to sign the build [Windows]
Profile string //Profile represents the name of the provisioning profile for this release build [iOS]
}
Expand Down
24 changes: 15 additions & 9 deletions internal/command/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ func (i *localContainerImage) cmd(vol volume.Volume, opts options, cmdArgs []str
}

mountFormat := "%s:%s:z"
if runtime.GOOS == darwinOS && runtime.GOARCH == string(ArchArm64) {
// When running on darwin with a Arm64, we rely on going through a VM setup that doesn't allow the :z
if runtime.GOOS == darwinOS {
// When running on darwin with an Arm64 or Amd64, we rely on going through a VM setup that doesn't allow the :z
mountFormat = "%s:%s"
}

Expand All @@ -129,19 +129,25 @@ func (i *localContainerImage) cmd(vol volume.Volume, opts options, cmdArgs []str
if runtime.GOOS != "windows" {
u, err := user.Current()
if err == nil {
args = append(args, "-u", fmt.Sprintf("%s:%s", u.Uid, u.Gid))
args = append(args, "--entrypoint", "fixuid")
if !debugging() {
// silent fixuid if not debug mode
cmdArgs = append([]string{"-q"}, cmdArgs...)
}
// Container runs as current host UID
args = append(args, "--user", u.Uid)
// Set HOME to something writable by the user
args = append(args, "-e", "HOME=/tmp")
}
}
}

// detect ssh-agent socket for private repositories access
if sshAuthSock := os.Getenv("SSH_AUTH_SOCK"); sshAuthSock != "" {
if realSshAuthSock, err := filepath.EvalSymlinks(sshAuthSock); err == nil {
if runtime.GOOS == "darwin" {
// Podman doesn't yet support sshagent forwarding on macOS
if !i.runner.engine.IsPodman() {
// on macOS, the SSH_AUTH_SOCK is not available in the container directly,
// but instead we need to the magic path "/run/host-services/ssh-auth.sock"
args = append(args, "-v", "/run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock")
args = append(args, "-e", "SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock")
}
} else if realSshAuthSock, err := filepath.EvalSymlinks(sshAuthSock); err == nil {
args = append(args, "-v", fmt.Sprintf("%s:/tmp/ssh-agent", realSshAuthSock))
args = append(args, "-e", "SSH_AUTH_SOCK=/tmp/ssh-agent")
}
Expand Down
13 changes: 9 additions & 4 deletions internal/command/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ func TestCmdEngineDocker(t *testing.T) {
log.Println(expectedCmd)

uid, _ := user.Current()
mountFlag := ":z"
if runtime.GOOS == darwinOS && runtime.GOARCH == string(ArchArm64) {
// When running on darwin with a Arm64, we rely on going through a VM setup that doesn't allow the :z
mountFlag = ""
}

workDir := filepath.Join(os.TempDir(), "fyne-cross-test", "app")
cacheDir := filepath.Join(os.TempDir(), "fyne-cross-test", "cache")
Expand Down Expand Up @@ -65,7 +70,7 @@ func TestCmdEngineDocker(t *testing.T) {
opts: options{},
cmdArgs: []string{"command", "arg"},
},
want: fmt.Sprintf("%s run --rm -t -w /app -v %s:/app:z --platform linux/amd64 -u %s:%s --entrypoint fixuid -e CGO_ENABLED=1 -e GOCACHE=/go/go-build %s -q command arg", expectedCmd, workDir, uid.Uid, uid.Gid, dockerImage),
want: fmt.Sprintf("%s run --rm -t -w /app -v %s:/app%s --platform linux/%s --user %s -e HOME=/tmp -e CGO_ENABLED=1 -e GOCACHE=/go/go-build %s command arg", expectedCmd, workDir, mountFlag, runtime.GOARCH, uid.Uid, dockerImage),
wantWindows: fmt.Sprintf("%s run --rm -t -w /app -v %s:/app:z --platform linux/amd64 -e CGO_ENABLED=1 -e GOCACHE=/go/go-build %s command arg", expectedCmd, workDir, dockerImage),
},
{
Expand All @@ -83,7 +88,7 @@ func TestCmdEngineDocker(t *testing.T) {
},
cmdArgs: []string{"command", "arg"},
},
want: fmt.Sprintf("%s run --rm -t -w %s -v %s:/app:z --platform linux/amd64 -u %s:%s --entrypoint fixuid -e CGO_ENABLED=1 -e GOCACHE=/go/go-build %s -q command arg", expectedCmd, customWorkDir, workDir, uid.Uid, uid.Gid, dockerImage),
want: fmt.Sprintf("%s run --rm -t -w %s -v %s:/app%s --platform linux/%s --user %s -e HOME=/tmp -e CGO_ENABLED=1 -e GOCACHE=/go/go-build %s command arg", expectedCmd, customWorkDir, workDir, mountFlag, runtime.GOARCH, uid.Uid, dockerImage),
wantWindows: fmt.Sprintf("%s run --rm -t -w %s -v %s:/app:z --platform linux/amd64 -e CGO_ENABLED=1 -e GOCACHE=/go/go-build %s command arg", expectedCmd, customWorkDir, workDir, dockerImage),
},
{
Expand All @@ -100,7 +105,7 @@ func TestCmdEngineDocker(t *testing.T) {
opts: options{},
cmdArgs: []string{"command", "arg"},
},
want: fmt.Sprintf("%s run --rm -t -w /app -v %s:/app:z -v %s:/go:z --platform linux/amd64 -u %s:%s --entrypoint fixuid -e CGO_ENABLED=1 -e GOCACHE=/go/go-build %s -q command arg", expectedCmd, workDir, cacheDir, uid.Uid, uid.Gid, dockerImage),
want: fmt.Sprintf("%s run --rm -t -w /app -v %s:/app%s -v %s:/go%s --platform linux/%s --user %s -e HOME=/tmp -e CGO_ENABLED=1 -e GOCACHE=/go/go-build %s command arg", expectedCmd, workDir, mountFlag, cacheDir, mountFlag, runtime.GOARCH, uid.Uid, dockerImage),
wantWindows: fmt.Sprintf("%s run --rm -t -w /app -v %s:/app:z -v %s:/go:z --platform linux/amd64 -e CGO_ENABLED=1 -e GOCACHE=/go/go-build %s command arg", expectedCmd, workDir, cacheDir, dockerImage),
},
{
Expand All @@ -118,7 +123,7 @@ func TestCmdEngineDocker(t *testing.T) {
opts: options{},
cmdArgs: []string{"command", "arg"},
},
want: fmt.Sprintf("%s run --rm -t -w /app -v %s:/app:z --platform linux/amd64 -u %s:%s --entrypoint fixuid -e CGO_ENABLED=1 -e GOCACHE=/go/go-build -e GOPROXY=proxy.example.com %s -q command arg", expectedCmd, workDir, uid.Uid, uid.Gid, dockerImage),
want: fmt.Sprintf("%s run --rm -t -w /app -v %s:/app%s --platform linux/%s --user %s -e HOME=/tmp -e CGO_ENABLED=1 -e GOCACHE=/go/go-build -e GOPROXY=proxy.example.com %s command arg", expectedCmd, workDir, mountFlag, runtime.GOARCH, uid.Uid, dockerImage),
wantWindows: fmt.Sprintf("%s run --rm -t -w /app -v %s:/app:z --platform linux/amd64 -e CGO_ENABLED=1 -e GOCACHE=/go/go-build -e GOPROXY=proxy.example.com %s command arg", expectedCmd, workDir, dockerImage),
},
}
Expand Down

0 comments on commit 5b88091

Please sign in to comment.