Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
padraicbc committed Apr 7, 2021
2 parents ca9cb6b + 243e41c commit 8c4e26e
Show file tree
Hide file tree
Showing 26 changed files with 1,354 additions and 458 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
goreleaser:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
-
name: Checkout
Expand All @@ -29,13 +29,19 @@ jobs:
name: Snapcraft Login
if: success() && startsWith(github.ref, 'refs/tags/v')
env:
SNAPCRAFT_LOGIN: ${{ secrets.snapcraft_token }}
SNAPCRAFT_TOKEN: ${{ secrets.snapcraft_token }}
run: |
snapcraft login --with <(echo "$SNAPCRAFT_LOGIN")
snapcraft login --with <(echo "$SNAPCRAFT_TOKEN")
-
name: Dockerhub Login
run: |
echo '${{ secrets.DOCKER_PASSWORD }}' | docker login --username '${{ secrets.DOCKER_USERNAME }}' --password-stdin
-
name: libssl1.1 => libssl1.0-dev for OSXCross
run: |
echo 'deb http://security.ubuntu.com/ubuntu bionic-security main' | sudo tee -a /etc/apt/sources.list
sudo apt update && apt-cache policy libssl1.0-dev
sudo apt-get install libssl1.0-dev
-
name: OSXCross for CGO Support
run: |
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
!.vscode/launch.json
*.code-workspace
.history

### Go ###
# Binaries for programs and plugins
*.exe
Expand Down
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ builds:
- darwin
goarch:
- amd64
- arm64
archives:
- replacements:
darwin: Mac
Expand Down
24 changes: 13 additions & 11 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,23 @@ func Build() error {
buildPath := filepath.Join(".", buildDir)

// Clear out any previous build dir of the same name.
if _, buildPathExistsErr := os.Stat(buildPath); buildPathExistsErr == nil {
build.Log("Removing old '" + buildPath + "' build directory")
if err = common.CheckErr(os.RemoveAll(buildPath)); err != nil {
return err
if !common.UseMemFS {
if _, buildPathExistsErr := os.Stat(buildPath); buildPathExistsErr == nil {
build.Log("Removing old '" + buildPath + "' build directory")
if err = common.CheckErr(os.RemoveAll(buildPath)); err != nil {
return err
}

}

}
// Create the buildPath directory.
if err := os.MkdirAll(buildPath, os.ModePerm); err != nil {
// bail on error in build
if err = common.CheckErr(fmt.Errorf("Unable to create \"%v\" build directory: %s", err, buildDir)); err != nil {
return err
}

// Create the buildPath directory.
if err := os.MkdirAll(buildPath, os.ModePerm); err != nil {
// bail on error in build
if err = common.CheckErr(fmt.Errorf("Unable to create \"%v\" build directory: %s", err, buildDir)); err != nil {
return err
}

}
build.Log("Creating '" + buildDir + "' build directory")

Expand Down
23 changes: 18 additions & 5 deletions cmd/build/assets_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package build
import (
"fmt"
"io"
"io/fs"
"os"
"path/filepath"
"strings"
Expand All @@ -27,12 +28,16 @@ func AssetsCopy(buildPath string, tempBuildDir string) error {
return fmt.Errorf("%s does not exist: %w", assetsDir, err)
}

err := filepath.Walk(assetsDir, func(assetPath string, assetFileInfo os.FileInfo, err error) error {
err := filepath.WalkDir(assetsDir, func(assetPath string, assetFileInfo fs.DirEntry, err error) error {
if err != nil {
return fmt.Errorf("can't stat %s: %w", assetPath, err)
}
destPath := buildPath + "/" + strings.TrimPrefix(assetPath, tempBuildDir)
if assetFileInfo.IsDir() {
// no dirs
if common.UseMemFS {
return nil
}
// Make directory if it doesn't exist.
// Move on to next path.
if err = os.MkdirAll(destPath, os.ModePerm); err != nil {
Expand All @@ -41,31 +46,39 @@ func AssetsCopy(buildPath string, tempBuildDir string) error {
return nil

}
if common.UseMemFS {
bd, err := os.ReadFile(assetPath)
if err != nil {
return fmt.Errorf("Could not open asset %s for copying: %w%s\n", assetPath, err, common.Caller())
}
common.Set(destPath, assetPath, &common.FData{B: bd})
return nil
}
from, err := os.Open(assetPath)
if err != nil {
return fmt.Errorf("Could not open asset %s for copying: %w%s", assetPath, err, common.Caller())
return fmt.Errorf("Could not open asset %s for copying: %w%s\n", assetPath, err, common.Caller())

}
defer from.Close()

to, err := os.Create(destPath)
if err != nil {
return fmt.Errorf("Could not create destination asset %s for copying: %w%s", destPath, err, common.Caller())
return fmt.Errorf("Could not create destination asset %s for copying: %w%s\n", destPath, err, common.Caller())

}
defer to.Close()

_, err = io.Copy(to, from)
if err != nil {
return fmt.Errorf("Could not copy asset from source %s to destination: %w%s", assetPath, err, common.Caller())
return fmt.Errorf("Could not copy asset from source %s to destination: %w%s\n", assetPath, err, common.Caller())

}

copiedSourceCounter++
return nil
})
if err != nil {
return fmt.Errorf("Could not get asset file: %w%s", err, common.Caller())
return fmt.Errorf("Could not get asset file: %w%s\n", err, common.Caller())

}

Expand Down
Loading

0 comments on commit 8c4e26e

Please sign in to comment.