Resolve prebuilt assets from the selected module
This commit is contained in:
@@ -3,11 +3,24 @@ package artifact
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const ManifestFilename = "SHA256SUMS"
|
||||
|
||||
// OutputDirectory resolves build output and prebuilt asset directories from
|
||||
// the absolute selected module directory.
|
||||
func OutputDirectory(moduleDir, directory string) string {
|
||||
if directory == "" {
|
||||
directory = "dist"
|
||||
}
|
||||
if !filepath.IsAbs(directory) {
|
||||
directory = filepath.Join(moduleDir, directory)
|
||||
}
|
||||
return filepath.Clean(directory)
|
||||
}
|
||||
|
||||
type Target struct {
|
||||
OS string
|
||||
Arch string
|
||||
|
||||
@@ -113,11 +113,11 @@ func BuildResolved(ctx context.Context, request Request) (Result, error) {
|
||||
}
|
||||
|
||||
if len(result.Targets) == 0 {
|
||||
result.OutputDir = resolvedOutputDir(moduleDir, request.OutputDir)
|
||||
result.OutputDir = artifact.OutputDirectory(moduleDir, request.OutputDir)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
result.OutputDir = resolvedOutputDir(moduleDir, request.OutputDir)
|
||||
result.OutputDir = artifact.OutputDirectory(moduleDir, request.OutputDir)
|
||||
declarations := artifact.ExpectedBuild(settings.BinaryName, identity.Version, settings.Targets)
|
||||
filenames := make([]string, len(declarations))
|
||||
for i, declaration := range declarations {
|
||||
@@ -204,19 +204,6 @@ func BuildResolved(ctx context.Context, request Request) (Result, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func resolvedOutputDir(moduleDir, outputDir string) string {
|
||||
if outputDir == "" {
|
||||
outputDir = filepath.Join(moduleDir, "dist")
|
||||
} else if !filepath.IsAbs(outputDir) {
|
||||
outputDir = filepath.Join(moduleDir, outputDir)
|
||||
}
|
||||
resolved, err := filepath.Abs(outputDir)
|
||||
if err != nil {
|
||||
return filepath.Clean(outputDir)
|
||||
}
|
||||
return resolved
|
||||
}
|
||||
|
||||
func gitCommit(ctx context.Context, repositoryDir string) (string, error) {
|
||||
command := exec.CommandContext(ctx, "git", "-C", repositoryDir, "rev-parse", "--verify", "HEAD^{commit}")
|
||||
output, err := command.Output()
|
||||
|
||||
Reference in New Issue
Block a user