Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support #102

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .github/workflows/go.build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ jobs:
echo "--> Building project for: ${os}/${arch}"
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -ldflags "-X github.com/flownative/localbeach/pkg/version.Version=${GITHUB_REF#refs/*/}" -o beach .
zip "beach_${os}_${arch}.zip" beach
ls -la
done

echo "--> Building project for: windows/amd64"
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X github.com/flownative/localbeach/pkg/version.Version=${GITHUB_REF#refs/*/}" -o beach.exe .
zip "beach_${os}_${arch}.zip" beach.exe

ls -la

- name: Archive build result (darwin/amd64)
uses: actions/upload-artifact@v4
with:
Expand All @@ -61,14 +66,20 @@ jobs:
name: beach-linux
path: beach_linux_amd64.zip

- name: Archive build result (windows)
uses: actions/upload-artifact@v4
with:
name: beach-windows
path: beach_windows_amd64.zip

- name: Create Release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
allowUpdates: true
artifactErrorsFailBuild: true
artifacts: "beach_linux_amd64.zip,beach_darwin_amd64.zip,beach_darwin_arm64.zip"
artifacts: "beach_linux_amd64.zip,beach_darwin_amd64.zip,beach_darwin_arm64.zip,beach_windows_amd64.zip"
artifactContentType: application/zip
generateReleaseNotes: false
makeLatest: true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/bin
/assets/compiled.go
/beach
/beach.exe
go_build_main_go
9 changes: 5 additions & 4 deletions pkg/beachsandbox/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package beachsandbox
import (
"errors"
"os"
"path"
"path/filepath"
"strings"

Expand All @@ -38,15 +37,17 @@ func detectProjectRootPathFromWorkingDir() (rootPath string, err error) {
}

func detectProjectRootPath(currentPath string) (projectRootPath string, err error) {
projectRootPath = path.Clean(currentPath)
projectRootPath = filepath.Clean(currentPath)
parentPath := filepath.Dir(projectRootPath)

if _, err := os.Stat(filepath.Join(projectRootPath, ".localbeach.docker-compose.yaml")); err == nil {
return projectRootPath, err
} else if projectRootPath == "/" {
} else if parentPath == projectRootPath {
// We have reached the root folder
return "", ErrNoLocalBeachConfigurationFound
}

return detectProjectRootPath(path.Dir(projectRootPath))
return detectProjectRootPath(parentPath)
}

func loadLocalBeachEnvironment(projectRootPath string) (err error) {
Expand Down
43 changes: 43 additions & 0 deletions pkg/path/path_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2019-2024 Robert Lemke, Karsten Dambekalns, Christian Müller
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// 💡 See https://golang.org/cmd/go/#hdr-Build_constraints for explanation of build constraints

//go:build windows

package path

import (
"log"
"os"
"path/filepath"
)

var OldBase = ""
var Base = ""
var Certificates = ""
var Database = ""

func init() {
homeDir, err := os.UserHomeDir()

if err != nil {
log.Fatal("Failed detecting home directory")
return
}

Base = filepath.Join(homeDir, ".LocalBeach")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably nonsense to use the ., as that is still visible on Windows. Maybe use UserConfigDir instead?

Certificates = filepath.Join(Base, "Certificates")
Database = filepath.Join(Base, "MariaDB")
}